如何修复错误:错误#2044:未处理的IOErrorEvent:。 text =错误#2035:找不到URL

时间:2011-05-25 20:37:44

标签: actionscript-3

我使用代码并收到错误

  

消息:错误#2044:未处理   IOErrorEvent :. text =错误#2035:URL   找不到。

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

如何解决这个问题?

2 个答案:

答案 0 :(得分: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' );
}

答案 1 :(得分:0)

你需要确保相对于.swf(而不是.fla)的目录库/存在,并且swf“test.swf”在该文件夹中,以便可以加载它。检查您的发布设置(shift + f12)以确保您的swf正在按预期发布。