1 Reply Latest reply on May 17, 2011 8:34 PM by Flex harUI

    MOUSE_DOWN, MOUSE_UP events work only if I set the style to my SkinnableContainer

    cpthk Level 1

      I am designing a physics container. Don't worry, my question is not  about the physics. Here is my code. Noticed that I have a  SetStyle statement there. I realized that if I don't have that line, the  MOUSE_DOWN, MOUSE_UP events won't work. If I do have that line, then  those events works fine. Anyone know the reason?

       

      package components
      {
           import flash.events.MouseEvent;
           
           import spark.components.SkinnableContainer;
           
           public class Test extends SkinnableContainer
           {
                
                private var mouseDown:Boolean;
                public function Test()
                {
                     super();
                     //setStyle("backgroundColor", "0xBBBBBB");
                     addEventListener(MouseEvent.MOUSE_DOWN, mouseDownEventHandler);
                     addEventListener(MouseEvent.MOUSE_UP, mouseUpEventHandler);
                }
                
                
                private function mouseDownEventHandler(mouseEvent:MouseEvent):void {
                     
                     mouseDown = true;
                }
                
                
                private function mouseUpEventHandler(mouseEvent:MouseEvent):void {
                     
                     mouseDown = false;
                }
           }
      }