Add mouse click listener to TextField
package{
import flash.display.GradientType;
import flash.display.Sprite;
import flash.geom.Matrix;
import flash.events.*;
import flash.text.*;
public class Main extends Sprite {
public function Main() {
var t:TextField = new TextField( );
t.text = "click here";
t.autoSize = TextFieldAutoSize.LEFT;
stage.addChild(t);
stage.addEventListener(MouseEvent.CLICK, clickListener, true);
stage.addEventListener(MouseEvent.CLICK, clickListener, false);
}
private function clickListener (e:MouseEvent):void {
var phase:String;
switch (e.eventPhase) {
case EventPhase.CAPTURING_PHASE:
phase = "Capture";
break;
case EventPhase.AT_TARGET:
phase = "Target";
break;
case EventPhase.BUBBLING_PHASE:
phase = "Bubbling";
break;
}
trace("Current event phase: " + phase);
}
}
}
Related examples in the same category