eventclass.as

来自「flash强大事件机制扩展类」· AS 代码 · 共 39 行

AS
39
字号
package 
{
	//----------------------------------------
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.HTTPStatusEvent;
	import flash.events.EventDispatcher;
	//----------------------------------------
	public class EventClass extends EventDispatcher
	{
		//----------------------------------------
		public function EventClass(url:String)
		{
			var loader:URLLoader = new URLLoader(new URLRequest(url));
			loader.addEventListener(Event.COMPLETE, this.completeHandler);
			loader.addEventListener(IOErrorEvent.IO_ERROR, this.ioErrorHandler);
			loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, this.httpStatusHandler);
		}
		public override function toString():String
		{
			return "[EventClass]";
		}
		private function completeHandler(evt:Event):void
		{
			this.dispatchEvent(new Event(Event.COMPLETE));
		}
		private function ioErrorHandler(evt:IOErrorEvent):void
		{
			this.dispatchEvent(new IOErrorEvent(evt.type, evt.bubbles, evt.cancelable, evt.text));
		}
		private function httpStatusHandler(evt:HTTPStatusEvent):void
		{
			this.dispatchEvent(new HTTPStatusEvent(HTTPStatusEvent.HTTP_STATUS, evt.bubbles, evt.cancelable, evt.status));
		}
		//----------------------------------------
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?