flex事件机制2:自定义事件
除了使用actionscript中的事件外,flex还允许开发者自定义事件。典型的自定义事件是继承flash.events.Event类,并在其中声明多个事件名称。如下:
package test.events
{
import flash.events.Event;
public class MyEvent extends Event
{
public function MyEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) {
super(type, bubbles, cancelable);
}
public static const EVENT_A:String = "event_A";
public static const EVENT_B:String = "event_B";
}
}
{
import flash.events.Event;
public class MyEvent extends Event
{
public function MyEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) {
super(type, bubbles, cancelable);
}
public static const EVENT_A:String = "event_A";
public static const EVENT_B:String = "event_B";
}
}