首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

Flex自定义事件时为啥要重载clone()方法(转载)

2012-11-19 
Flex自定义事件时为什么要重载clone()方法(转载)?声明:转载以前在private function relay(customEvent:Cus

Flex自定义事件时为什么要重载clone()方法(转载)

?

声明:转载

以前在private function relay(customEvent:CustomEvent):void{dispatchEvent(customEvent);}

?

这个relay方法就是对CustomEvent的第一次响应,然后在这个方法里继续向外派发这个事件,由另一个事件处理器来继续处理;在重新派发事件的过程中,flash内部的事件<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"xmlns:MyComp="mycomponents.*" creationComplete="initApp()"><mx:Script><![CDATA[import myevents.EnableChangeEvent;import mx.controls.Alert;private function initApp():void{this.addEventListener(EnableChangeEvent.ENABLE_CHANGED,relistenEvent);}private function enableChangedListener(event:EnableChangeEvent):void{// Handle event.myTA.text = "Event isEnabled: "+event.isEnabled;dispatchEvent(event);}private function relistenEvent(event:EnableChangeEvent):void{Alert.show("isEnabled? "+event.isEnabled,"EventHandled");}]]></mx:Script><MyComp:MyButton label="ClickMe" enableChanged="enableChangedListener(event)"/><mx:TextArea id="myTA"/</mx:Application>

<?xml version="1.0" encoding="utf-8"?><mx:Button xmlns:mx="http://www.adobe.com/2006/mxml"click="buttonClickHandler()"><mx:Script><![CDATA[import myevents.EnableChangeEvent;public function buttonClickHandler():void{dispatchEvent(new EnableChangeEvent('enableChanged',true));}]]></mx:Script><mx:Metadata>Event(name="enableChanged", type="myevents.EnableChangeEvent")]</mx:Metadata></mx:Button>

?

package myevents{import flash.eventsEvent;public class EnableChangeEvent extends Event{public static const ENABLE_CHANGED:String="enableChanged";public var isEnabled:Boolean;public function EnableChangeEvent(type:String, isEnabled:Boolean=false){super(type);this.isEnabled=isEnabled;}//override public function clone():Event//{//return new EnableChangeEvent(type, isEnabled);//}}}
?

?

?

热点排行