The immutable event flow
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.events.*;
public class Main extends Sprite {
private var textField:TextField;
public function Main( ) {
textField = new TextField( );
textField.text = "Click here";
textField.autoSize = TextFieldAutoSize.LEFT;
addChild(textField);
stage.addEventListener(MouseEvent.CLICK, stageClickListener, true);
textField.addEventListener(MouseEvent.CLICK, textFieldClickListener);
}
private function stageClickListener (e:MouseEvent):void {
if (e.target == textField) {
removeChild(textField);
textField = null;
}
}
private function textFieldClickListener (e:MouseEvent):void {
trace("textFieldClickListener triggered");
}
}
}
|