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

Actionscript 3 如何修复错误:错误#2044:未处理的IOErrorEvent:。text=错误#2035:找不到URL,actionscript-3,Actionscript 3,我使用了代码,但我得到了一个错误 消息:错误#2044:未处理 IOErrorEvent:。text=错误#2035:URL 没有找到 如何修复此问题?您需要确保目录库/相对于.swf(而不是.fla)存在,并且swf“test.swf”位于该文件夹内,以便可以加载它。检查您的发布设置(shift+f12)以确保您的swf在您期望的位置发布。必须添加侦听器 var context:LoaderContext = new LoaderContext(); context.checkPoli

我使用了代码,但我得到了一个错误

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


如何修复此问题?

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

必须添加侦听器

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' );
}

我尝试了您的代码,然后出现以下错误:TypeError:error#1009:无法访问null对象引用的属性或方法。在test_fla::GRIDGALLERY_1/frame1()类型错误:错误#1009:无法访问空对象引用的属性或方法。在test\u fla::GRIDGALLERY\u 1/在test\u fla::GRIDGALLERY\u 1/在flash.events::EventDispatcher/dispatchEventFunction()在flash.net::URLLoader/onComplete()在flash.events::EventDispatcher/dispatchEvent()在flash.net::URLLoader/onComplete()什么对象是空对象?什么线路?我将制作一个工作副本并测试它的代码是否适合我。我所做的只是将代码复制粘贴到一个新的FLA中,并将url更改为下载文件。我还在我的代码中为您添加了跟踪语句将代码格式添加到您的代码中。只需在行首添加4个空格,使其代码格式化。在调试器中测试时是否在本地发生此错误?另外,此代码所在的.swf是另一个.swf加载的还是html页面?此外,请检查此处列出的url路径的大小写,以确保它完全匹配。
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' );
}