Skip to main content
August 19, 2013
Answered

flash AIR app cannot load child swfs on publish to device

  • August 19, 2013
  • 1 reply
  • 4603 views

I have been struggling with this problem for WEEKS now and can't solve it. I have an flash AIR app (creative cloud, AIR 3.8) which is very simple: all it does is load external SWF movies on the click of a start button. It works FINE in test/PC but when I publish to device, the external swfs do not load.

Here is the code on the main timeline that calls the external swfs:

//start button

start_button_TRI_desmatosuchus.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_02_3,false,0,true);

import fl.display.ProLoader;

import flash.events.Event;

var fl_ProLoader_02:ProLoader;

var fl_ToLoad_02:Boolean = true;

function fl_ClickToLoadUnloadSWF_02_3(event:MouseEvent):void

{

          if(fl_ToLoad_02)

          {

                    fl_ProLoader_02 = new ProLoader();

                    fl_ProLoader_02.load(new URLRequest("dinofilms/triassic_desmatosuchus.swf"));

                    fl_ProLoader_02.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete_02)

                    addChild(fl_ProLoader_02);

                    fl_ProLoader_02.x = 0;

                    fl_ProLoader_02.y = 144;

          }

          else

          {

                    if (fl_ProLoader_02!=null) {

                              removeChild(fl_ProLoader_02);

                              fl_ProLoader_02.unloadAndStop();

                              fl_ProLoader_02 = null;

                    }

          }

          fl_ToLoad_02 = !fl_ToLoad_02;

 

}

function onComplete_02(e:Event):void {

          e.currentTarget.content.addEventListener(Event.ENTER_FRAME,OEF_02);

}

function OEF_02(e:Event):void {

          if (e.currentTarget.currentFrame==e.currentTarget.totalFrames) {

                    e.currentTarget.stop();

                    e.currentTarget.removeEventListener(Event.ENTER_FRAME,OEF_02);

 

                    removeChild(fl_ProLoader_02);

                    fl_ProLoader_02.unloadAndStop();

                    fl_ProLoader_02 = null;

          }

}

I am calling about 30 different movies on 30 different frames, so that's why I am using tags like "proLoader_01" so I don't duplicate them. All the external swfs are of course listed in the included files too.

I would really appreciate the assistance, I am a reluctant coder!

Message was edited by: Fiona Passantino

This topic has been closed for replies.
Correct answer kglad

I found this on the AIR forum, does it mean something to you?

"*The minor change is that when loading the SWF, the application domain should be the same as that of the main SWF i.e. ApplicationDomain.currentDomain."

From here: http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/

I of course have no idea what this means, but maybe someone out there does??


yes, that's important when you load swfs that contain actionscript and you need that loaded actionscript to work and is something i alluded to in message 9. 

it's not relevant to your problem unless you've mis-explained the problem.  from your description, you're not seeing the loaded swfs load.  if the swfs actually load without problem, but they contain actionscript that does not work, you need to correct the description of your problem.

***************************************************************************************************

edit:  the above is not correct.  you do need to declare a loadercontext when loading an external swf with the newer (3.6+) air sdk's even if the external swfs contain no actionscript.  otherwise, the load() method (and any code appearing thereafter) fails to execute

so, use something like:

loader = new Loader();

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

loader.load(new URLRequest("dinofilms/cretaceous_ankylosaurus.swf"),lc);

1 reply

kglad
Community Expert
Community Expert
August 19, 2013

your external swfs need to be added to the included files field in your publish for mobile settings panel.

August 19, 2013

Oh, that's of course already the case! Any other suggestions?

kglad
Community Expert
Community Expert
August 19, 2013

your target may not support proloader.  try using the loader class.