【问题标题】:How to fix the error: Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found如何修复错误:错误 #2044:未处理的 IOErrorEvent:。文本=错误 #2035:未找到 URL
【发布时间】:2011-05-25 20:37:43
【问题描述】:

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

消息:错误 #2044:未处理 IOError事件:。文本=错误 #2035:网址 未找到。

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

如何解决这个问题?

【问题讨论】:

  • 为您的代码添加代码格式。只需在行首添加 4 个空格,即可对其进行代码格式化。
  • 在调试器中测试时是否在本地发生此错误?此外,此代码所在的 .swf 是由另一个 .swf 加载还是加载到 html 页面中?另外,检查那里列出的 url 路径的大小写,以确保它完全匹配。

标签: actionscript-3


【解决方案1】:

必须添加监听器

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:错误#1009:无法访问空对象引用的属性或方法。在 test_fla::GRIDGALLERY_1/frame1() 类型错误:错误 #1009:无法访问空对象引用的属性或方法。在 test_fla::GRIDGALLERY_1/set_normalscreen_xy() 在 test_fla::GRIDGALLERY_1/create_gallery() 在 flash.events::EventDispatcher/dispatchEventFunction() 在 flash.events::EventDispatcher/dispatchEvent() 在 flash.net::URLLoader/onComplete( )
  • 空对象是什么对象?什么线?我会制作一份工作副本并测试它
  • 代码对我来说很好用。我所做的只是将代码复制并粘贴到一个新的 FLA 中,并将 URL 更改为下载文件。我还在我的代码中为你添加了跟踪语句
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    相关资源
    最近更新 更多