Why does the roll_out event fire in this code?

Posted by user339681 on Stack Overflow See other posts from Stack Overflow or by user339681
Published on 2010-05-24T12:44:18Z Indexed on 2010/05/24 13:11 UTC
Read the original article Hit count: 180

Filed under:

I have made this simple example to demonstrate some problems I'm having.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Canvas
        id="buttonCanvas"
        x="100" y="100" opaqueBackground="#000000" width="80%" height="300"
        creationComplete="init(event)">
        <mx:Button x="5" y="5"/>
        <mx:Button x="5" y="50"/>

    </mx:Canvas>


    <mx:Script>
    <![CDATA[
        private function init(event:Event):void{
            buttonCanvas.addEventListener(MouseEvent.ROLL_OUT, function(event:Event):void{
                buttonCanvas.opaqueBackground=(buttonCanvas.opaqueBackground==0)? 0x666666:0;
            });         
        }    
    ]]>
    </mx:Script>
</mx:Application>

I don't understand the following:

  1. Why doesn't the percentage nor absolute dimensions affect the canvas?
  2. Why does the roll_out event fire when the mouse leaves a button (even when it is still inside the canvas).

I'm going nuts trying to figure this out. Any help would be greatly appreciated!

© Stack Overflow or respective owner

Related posts about flex