0

I'm on a project created in Flash Builder 4.7 and Flash Professional CS6, nice. I need the project load's a SWF inside the "preloaded SWF",

  • The first SWF, loads a second SWF,

  • This second SWF would be the "Home" of the project.

At this point, it work's perfectly. But when the "Home" try to load other external SWF, it says :

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2124"]

The code of the first SWF:

public class InitialSWF extends MovieClip
{

  private var _loader_:Loader;

  private var _applicationContent_:DisplayObject;

  private var _loaderContent_:MovieClip;

  private var _loaderIcon_:MovieClip;

  public function InitialSWF()
  {
     super();
     _loader_ = new Loader();
     _loader_.contentLoaderInfo.addEventListener(Event.COMPLETE,_onComplete_,false,0,true);
     _loader_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,_onIoError_,false,0,true);
     _loader_.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,_onProgress_,false,0,true);
     _loader_.load(new URLRequest("Home.swf"));
  }

  private function _onComplete_(param1:Event) : void
  {
     _applicationContent_ = _loader_.content;
     _applicationContent_.visible = true;
     stage.addChild(_applicationContent_);
     _applicationContent_.addEventListener("onApplicationComplete",_onApplicationComplete_,false,0,true);
     _loader_.contentLoaderInfo.removeEventListener(Event.COMPLETE,_onComplete_);
     _loader_.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,_onIoError_);
     _loader_.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,_onProgress_);
     _loader_.unload();
     _loader_ = null;
  }

  private function _onApplicationComplete_(tmpEvt:Event) : void
  {
     _applicationContent_.removeEventListener("onApplicationComplete",_onApplicationComplete_);
     _loaderContent_.addEventListener("loaderOut",_onLoaderOut_,false,0,true);
     // do something
  }

  private function _onLoaderOut_(param1:Event) : void
  {
     _loaderContent_.removeEventListener("loaderOut",_onLoaderOut_);
     _applicationContent_.visible = true;
     stage.removeChild(this);
  }

  private function _onIoError_(tmpError:IOErrorEvent) : void
  {
      trace(tmpError);
  }

  private function _onProgress_(param1:ProgressEvent) : void
  {
     var _progress_:Number = Math.round(param1.bytesLoaded / param1.bytesTotal * 100);
     //Do animation loading
  }

And the HomeSWF:

public class SecondarySWF extends Sprite
{

    private var _loader_:Loader;

    private var _loaderContent_:MovieClip;

    private var _loaderIcon_:MovieClip;

    private var _applicationContent_:DisplayObject;

    public function SecondarySWF()
    {
        this.addEventListener(Event.ADDED_TO_STAGE,this._GoLogin_,false,0,true);
    }

    public function _GoLogin_(tmpEvent:Event)
    {
        _loader_ = new Loader();
        _loader_.contentLoaderInfo.addEventListener(Event.COMPLETE,_onComplete_,false,0,true);
        _loader_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,_onIoError_,false,0,true);
        _loader_.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,_onProgress_,false,0,true);
        _loader_.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
        _loader_.load(new URLRequest("SecondarySWF.swf"));
    }

    private function httpStatusHandler(event:HTTPStatusEvent):void {
        trace(event);
    }

    private function _onComplete_(param1:Event) : *
    {
        _applicationContent_ = _loader_.content;
        _applicationContent_.visible = true;
        stage.addChild(_applicationContent_);
        _applicationContent_.addEventListener("onApplicationComplete",_onApplicationComplete_,false,0,true);
        _loader_.contentLoaderInfo.removeEventListener(Event.COMPLETE,_onComplete_);
        _loader_.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,_onIoError_);
        _loader_.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,_onProgress_);
        _loader_.unload();
        _loader_ = null;
        this.removeEventListener(Event.ADDED_TO_STAGE,this._GoLogin_);
    }

    private function _onApplicationComplete_(param1:Event) : void
    {
        _applicationContent_.removeEventListener("onApplicationComplete",_onApplicationComplete_);
        _loaderContent_.addEventListener("loaderOut",_onLoaderOut_,false,0,true);
        // ..
    }

    private function _onLoaderOut_(param1:Event) : void
    {
        _loaderContent_.removeEventListener("loaderOut",_onLoaderOut_);
        //_applicationContent_.visible = true;
        //stage.removeChild(this);
    }

    private function _onIoError_(tmpError:IOErrorEvent) : void
    {
        trace(tmpError);
    }

    private function _onProgress_(param1:ProgressEvent) : void
    {
        var _progress_:Number = Math.round(param1.bytesLoaded / param1.bytesTotal * 100);
        // ..
    }
}

ConsoleChromeSWF <-This is an image of the Google console.log, and catch this:

  • start InitialSWF
  • Load HomeSWF
  • Complete loaded of HomeSWF
  • Start HomeSWF
  • The link of the Secondary SWF (censored/hidden from public)
  • Load SecondarySWF
  • ERROR

I don't know why the Secondary SWF is 100% loaded but return an error... Regards!

Kohei TAMURA
  • 4,970
  • 7
  • 25
  • 49
  • IO error means that the URL of secondary SWF is wrong. My **guess** is that you are using relative URLs while not understanding completely how they work. I've explained it here: https://stackoverflow.com/questions/43452676/game-assets-not-loading-in-kongregate/43457482#43457482 – Organis Jul 28 '17 at 10:26
  • Really I use this for call the URLRequest: var _tmpStr_:String = null; var _loaderURL_:String = loaderInfo.loaderURL; var _loaderLength_:int = _loaderURL_.length - 1; while(_loaderLength_ > -1) { if(_loaderURL_.charAt(_loaderLength_) == "/" || _loaderURL_.charAt(_loaderLength_) == "\\") { _tmpStr_ = _loaderURL_.substring(0,_loaderLength_ + 1); break; } _loaderLength_--; } – FranYork Jul 29 '17 at 18:57
  • this is not the error, because if a trace the full url of the request is: http://localhost/someSWF/file.swf?v=48743, for example – FranYork Jul 29 '17 at 18:59
  • Ok. Wrong URL was just a guess worth checking. Next step then. Instead of **Loader** use **URLLoader** to load secondary SWF as binary data and check (a) data length and (b) data content. Why? Because error 2124 is a "wrong file type" IO error, which just **might** mean server outputs something other than secondary SWF upon your request. – Organis Jul 29 '17 at 23:12

0 Answers0