2011-05-25 158 views
3

我使用的代碼,我得到一個錯誤如何解決該錯誤:錯誤#2044:未處理的IOErrorEvent :.文字=錯誤#2035:找不到網址

msg: Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

var myLoader:Loader = new Loader(); 
addChild(myLoader); 
var url:URLRequest = new URLRequest("gallery/test.swf"); 
myLoader.load(url); 

如何解決這一問題?

+0

添加代碼格式化你的代碼。只需在行的開頭添加4個空格以使其代碼格式化即可。 – prototypical 2011-05-25 22:02:41

+0

在調試器中測試時是否發生本地錯誤?另外,這個代碼是在.swf中,由另一個.swf加載還是加載到一個html頁面中?另外,請檢查那裏列出的url路徑的大小寫,以確保它匹配正確。 – prototypical 2011-05-25 22:08:03

回答

0

您需要確保目錄庫/存在相對於您的.swf(不是您的.fla),並且swf「test.swf」位於該文件夾內部,以便它可以加載。檢查你的發佈設置(shift + f12)以確保你的swf發佈在你期望的位置。

+0

我檢查,但我仍然得到這個錯誤。 – user608518 2011-05-25 21:21:55

6

得添加監聽

var context:LoaderContext = new LoaderContext(); 
    context.checkPolicyFile = true; 

var url:URLRequest = new URLRequest("gallery/test.swf"); 

var myLoader:Loader = new Loader(); 
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete); 
    myLoader.addEventListener(AsyncErrorEvent.ASYNC_ERROR, errorHandlerAsyncErrorEvent); 
    myLoader.addEventListener(IOErrorEvent.IO_ERROR, errorHandlerIOErrorEvent); 
    myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandlerSecurityErrorEvent); 
    myLoader.contentLoaderInfo.addEventListener(Event.INIT, initHandler); 
    myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, infoIOErrorEvent); 
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener); 

    myLoader.load(url,context); 
    myLoader.load(url); 



function progressListener (e:ProgressEvent):void{ 
    trace("Downloaded " + e.bytesLoaded + " out of " + e.bytesTotal + " bytes"); 
} 
function initHandler(e:Event):void{ 
    trace('load init'); 
} 
function errorHandlerErrorEvent(e:ErrorEvent):void{ 
    trace('errorHandlerErrorEvent ' + e.toString()); 
} 
function infoIOErrorEvent(e:IOErrorEvent):void{ 
    trace('infoIOErrorEvent ' + e.toString()); 
} 
function errorHandlerIOErrorEvent(e:IOErrorEvent):void{ 
    trace('errorHandlerIOErrorEvent ' + e.toString()); 
} 
function errorHandlerAsyncErrorEvent(e:AsyncErrorEvent) :void{ 
    trace('errorHandlerAsyncErrorEvent ' + e.toString()); 
} 
function errorHandlerSecurityErrorEvent(e:SecurityErrorEvent):void{ 
    trace('errorHandlerSecurityErrorEvent ' + e.toString(
                 )); 
} 
function onLoadComplete(e:Event):void{ 
    trace('onLoadComplete'); 
} 
+0

我試過你的代碼,然後我得到這個錯誤:TypeError:Error#1009:Can not access a property or method of null object reference。 \t at test_fla :: GRIDGALLERY_1/frame1() TypeError:錯誤#1009:無法訪問空對象引用的屬性或方法。 \t在test_fla :: GRIDGALLERY_1/set_normalscreen_xy() \t在test_fla :: GRIDGALLERY_1/create_gallery() \t在flash.events::EventDispatcher/dispatchEventFunction() \t在flash.events::EventDispatcher/dispatchEvent() \t在flash.net::URLLoader/onComplete() – user608518 2011-05-25 21:33:35

+0

什麼對象是空對象?什麼線?我將製作一份工作副本並對其進行測試 – 2011-05-25 21:35:30

+0

代碼適合我。我所做的只是將代碼複製並粘貼到新的FLA中,並將url更改爲下載文件。我還在代碼中爲您添加了跟蹤語句 – 2011-05-25 21:42:13

相關問題