Skip to main content
Participant
October 4, 2013
Question

loading swf asset at runtime iOS fail

  • October 4, 2013
  • 0 replies
  • 304 views

Ok this one is weird:

I have an app, and at runtime I load a swf (out of possible 2) based on the hardware (iPhone vs iPad). When I run a debug build on the device, both devices work. When I make Final Release It only loads the iPad swf. When run on the iPhone it just stops at ~93% when loading and does nothing; no error event, no throws.

This is what my dir structure is like:

bin-debug

     -main.swf

     -assets

          -iphone

               -mySWF.swf

          -ipad

               -mySWF.swf

Now for the punchline: if I rename the "iphone" directory to "i1phone" so that it is listed above "ipad" folder (because iOS sorts it alphabetically, or whatever) the iphone swf now magically runs! And yes, you guessed it, it stops working on an iPad in that case.

It seams that iOS will only load the first swf in its bundle list and fail on all subsequent ones.

Code:

public function main()

{

if(stage.fullScreenHeight == 1024 || stage.fullScreenHeight == 2048 || stage.fullScreenWidth == 1024 || stage.fullScreenWidth == 2048)

             {

                                             device = "ipad";

                              }

            else

                              {

                      device = "iphone";

                              }

  var _urlRequest:URLRequest = new URLRequest("assets/"+device+"/mySWF.swf");

  var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);

  _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadCompelte);

  _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);

  _loader.load(_urlRequest, _lc);

}


private function onLoadCompelte(e:Event😞void

{

       addChild(_loader);

  }

  private function onError(e:IOErrorEvent😞void

  {

        trace(e.text);

   }


Using FB 4.7, AIR 3.7 with -swf-version=20 for all swfs (including main).

Forgot to mention things I tried:

1. renaming the actual swf filenames so that they are not the same

2. uhh

This topic has been closed for replies.