⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 event.as

📁 flash强大事件机制扩展类
💻 AS
字号:
//----------------------------------------
/*
@Description:  	事件类的基类.触发事件时,是事件侦听的参数.如果需要传递参数,你可以继承此类.
@usage:   		dispatchEvent(new Event(Event.COMPLETE));
				addEventListener(Event.COMPLETE, listenerObject);
				removeEventListener(Event.COMPLETE, listenerObject);
@example: 
//EventClass.as
//----------------------------------------
import AS2.utils.CFDelegate;
import AS2.events.Event;
import AS2.events.CFEventDispatcher;
//----------------------------------------
class EventClass extends CFEventDispatcher
{
	//----------------------------------------
	public var tXML:XML;
	//----------------------------------------
	public function EventClass(url:String)
	{
		this.tXML = new XML();
		this.tXML.onLoad = CFDelegate.create(this, this.XMLonLoad);
		this.tXML.load(url);
	}
	public function toString():String
	{
		return "[EventClass]";
	}
	private function XMLonLoad(success:Boolean):Void
	{
		if (success) {
			this.dispatchEvent(new Event(Event.COMPLETE));
		}
	}
	//----------------------------------------
}

//
// EventExample.as
//----------------------------------------
import EventClass;
import AS2.events.Event;
//----------------------------------------
class EventExample
{
	public function EventExample()
	{
		var ee:EventClass = new EventClass("EventExample.xml");
		ee.addEventListener(Event.COMPLETE, this.completeHandler);
	}
	private function completeHandler(evt:Event):Void
	{
		trace(evt);
	}
}
//
// EventExample.fla
new EventExample();
//
@author:  ChooseFlash
@date:	  2007-07-07
*/
//----------------------------------------
class AS2.events.Event extends Object
{
	//----------------------------------------
	//事件的常数名.
	public static var COMPLETE:String = "complete";
	public static var CANCEL:String = "cancel";
	public static var CHANGE:String = "change";
	public static var CLOSE:String = "close";
	public static var CONNECT:String = "connect";
	public static var FULLSCREEN:String = "fullScreen";
	public static var OPEN:String = "open";
	public static var REMOVED:String = "removed";
	public static var RESIZE:String = "resize";
	public static var SCROLL:String = "scroll";
	public static var SELECT:String = "select";
	//----------------------------------------
	public var type:String;
	public var target:Object;
	//----------------------------------------
	private var className:String = "Event";
	//----------------------------------------
	//构造函数.
	public function Event(type:String)
	{
		this.type = type;
	}
	//----------------------------------------
	public function toString():String
	{
		var str:String = "";
		for (var i:String in this) {
			if (this[i] != undefined) {
				str += i + "=" + this[i] + " ";
			}
		}
		return "[" + this.className + " " + str.slice(0,str.length - 1) + "]";
	}
	//----------------------------------------
}

⌨️ 快捷键说明

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