Click Test : MouseEvent : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » MouseEvent »

 

Click Test


 
package {

     import flash.display.Sprite;
     import flash.events.MouseEvent;
     
     [SWF(width=550, height=400)]
     
     public class Main extends Sprite {
          
          public function Main() {
               var square:Sprite = new Sprite();
               square.graphics.lineStyle(20x000000);
               square.graphics.beginFill(0xff0000);
               square.graphics.drawRect(00100100);
               square.graphics.endFill();
               addChild(square);
               
               square.doubleClickEnabled = true;
               
               square.addEventListener(MouseEvent.CLICK, onSquareClick);
               square.addEventListener(MouseEvent.DOUBLE_CLICK, onSquareDoubleClick);
          }
          
          private function onSquareClick(event:MouseEvent):void {
               trace("ouch!");
          }
          
          private function onSquareDoubleClick(event:MouseEvent):void {
               trace("double ouch!");
          }
     
     }

}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» MouseEvent