首页 > 代码库 > as3.0自定义事件。

as3.0自定义事件。

今天看到一个容易理解的as3.0自定义事件实例:

package {	import flash.display.Sprite;	import flash.events.MouseEvent;	import flash.events.EventDispatcher;	public class myClip extends Sprite {		public function myClip() {			addEventListener(MouseEvent.CLICK,clickHander);		}		private function clickHander(evt:MouseEvent):void {						var _clipEvent:clipEvent=new clipEvent();			_clipEvent.M="wangyan";			dispatchEvent(_clipEvent);		}	}}//库绑定类package {	import flash.events.Event;	public class clipEvent extends Event {		public static const CLIP_CLICK:String="clip_click";		private var _mm:String;		public function clipEvent() {			super(CLIP_CLICK);		}		public function get M() {			return _mm;		}		public function set M(a:String) {			_mm=a;		}	}}//自定义事件类function listen_clipEvent(evt:clipEvent) {	trace("hello"+evt);}abc.addEventListener(clipEvent.CLIP_CLICK,listen_clipEvent);