Mouse Events and Overlapping Display Objects : MouseEvent : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » MouseEvent »

 

Mouse Events and Overlapping Display Objects


 
package {
  import flash.display.*;
  import flash.events.*;
  import flash.text.*;

  public class Main extends Sprite {
    public function Main (  ) {
      var circle:Sprite = new Sprite(  );
      circle.graphics.beginFill(0x9999991);
      circle.graphics.lineStyle(1);
      circle.graphics.drawEllipse(00100100);

      var textfield:TextField = new TextField(  );
      textfield.text = "Click here";
      textfield.autoSize = TextFieldAutoSize.LEFT;
      textfield.x = 30;
      textfield.y = 30;
      textfield.border = true;
      textfield.background = true;

      addChild(circle);
      addChild(textfield);

      circle.addEventListener(MouseEvent.CLICK, clickListener);
    }

    private function clickListener (e:MouseEvent):void {
      trace("User clicked: " + e.target);
      DisplayObject(e.target).x += 10;
    }
  }
}

        



Leave a Comment / Note


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


Flash / Flex / ActionScript examples

 Navioo Development
» MouseEvent