ActionScript的很多写法与JavaScript的写法很像
var button:Button = new Button;
button.label = "按钮";
button.id = "button_1";
button.addEventListener(MouseEvent.CLICK, clickHandler("hello"));
或者如下
//button.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void{clickChangeHandler(e, "hello")});
private function clickHandler(title:String):Function{
return function(e:MouseEvent):void{
clickChangeHandler.apply(null, [e, title])};
}
private function clickChangeHandler(event:Event, title:String):void{
Alert.show(title);
}