0
我試圖動態地建立了聽衆一些默認的回調,而我並沒有在此刻很大的成功動態應用的功能。在AS3
陣:
var URLLoader_SharedCallbacks:Array = new Array();
URLLoader_SharedCallbacks.push(new Array (HTTPStatusEvent, HTTPStatusEvent.HTTP_STATUS, "URLLoader_HTTPStatus"));
URLLoader_SharedCallbacks.push(new Array (IOErrorEvent, IOErrorEvent.IO_ERROR, "URLLoader_IOError"));
URLLoader_SharedCallbacks.push(new Array (Event, Event.OPEN, "URLLoader_Open"));
然後:
function URLLoader_SharedCallbacks_Add(ul:URLLoader):void
{
for each(var arr:Array in this.URLLoader_SharedCallbacks)
{
var fnc:Function = function(evt:arr[0])
{
trace("evt = " + evt)
}
if(!this[ul].hasEventListener(arr[2]))
{
this[ul].addEventListener(fnc);
}
}
}
建議?
動態將是理想的,但在尋找你的以上的解決方案,似乎最終它幾乎與簡單地說「長路」一樣冗長。我可以肯定看到上面的代碼以備後用一些可能的用途,所以感謝您的:) – Eric 2010-11-04 13:52:02
最終我做了一個函數,做了重複的工作,然後叫從每個回調函數,並通過應用的addEventListener個別回調函數。這將代碼削減了很多。再次感謝您的幫助,ww0z0k! – Eric 2010-11-04 13:53:47