Error #2044: 未处理的 IOErrorEvent:。 text=Error #2124: 加载的文件为未知类型。
解决方案:
 

背景:当我们做游戏的时候,需要加载外部SWF文件是,经常需要对本地版本和网络版本之间进行切换,上传到网络上去的版本就要手动修改SWF文件的加载URL,每次上传都要修改!有没有什么方法不进行修改直接上传到网络上就可以呢?
  方法:当然有一般的采取的办法如下:
           try
            {   
                //本地版
                GameLoader.load(new URLRequest("miniGame/PorterGame.swf"));
               
            }catch (e:Error)
            {   
               //网络版
                GameLoader.load(new URLRequest("http://sns.games.org/swf/PorterGame.swf"));
            }
            GameLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, CompleteHandler);
            GameLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, ProgressHandler);
但是我们最终发现上面的方法不行,我们得到的往往是 : Error #2044: 未处理的 IOErrorEvent:。 text=Error #2124: 加载的文件为未知类型。
解决方案:加入监听: GameLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onError);
然后再onError里面重新加载SWF文件,这样就可以了,onError中的代码如下:
    GameLoader.load(new URLRequest(GamePath));
    GameLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, CompleteHandler);
    GameLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, ProgressHandler);
    GameLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onError);