`
superwulei
  • 浏览: 106419 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Custom Event in Flex

阅读更多
关于Flex中自定义事件的创建步骤,在Adobe一周视频上是这样讲述的:

   1. Define the event with the event metadata tag.
   2. Instantiate the event.
   3. Dispatch the event.
   4. Create an event handler.
   5. Use the information/data in the event object.

步骤详解:
For 1: 在metadata标记中定义event
<mx:Metadata>
    [Event(name="eventName", type="flash.events.Event")]
</mxMetadata>
For 2/3: 首先在控件中,如按钮等的系统事件中调用yourHandler,例如click="yourHandler"。其中yourHandler是你自己定义的方法,如下:
private functionyourHandler(event:Event):void{
    var eventObj:Event = new Event("eventName");
    dispatchEvent(eventObj);
}
For 4/5: 最后定义自定义时间的Handler,并在这个Handler中定义你需要做的业务功能。
private functioneventNameHandler(event:Event):void{
   //your bussiness logic here.
}
最后在被触发的控件上就可以使用eventName="eventNameHandler(event)"了。
1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics