flex 全局分发,监听 事件
package { import flash.events.EventDispatcher; import flash.events.IEventDispatcher; public class MessageDispatch extends EventDispatcher { private static var instance:MessageDispatch; public function MessageDispatch(target:IEventDispatcher=null) { super(target); } public static function getInstance():MessageDispatch { if(instance==null) { instance=new MessageDispatch(); } return instance; } public var msg:String } }
MessageDispatch.getInstance().dispatchEvent(new Event("send",true));
MessageDispatch.getInstance().addEventListener("send",sendmethod);
protected function sendmethod(event:Event):void { Alert.show("send","msg",1,this); }
不写注释了.很简单的代码.分发后,可以全局进行监听
作者:javaoraspx
出处:http://www.cnblogs.com/xyong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。