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);
}
本文介绍了如何使用ActionScript实现按钮点击事件的监听与处理。通过示例代码展示了如何创建按钮,设置属性,并添加点击事件监听器。同时,还提供了一个自定义函数用于处理点击事件。
2723

被折叠的 条评论
为什么被折叠?



