Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

loading multiple swf's with addChild without blinking in between

Community Beginner ,
Jul 27, 2014 Jul 27, 2014

I have a shell Flash that pulls in a swf file.  When you hit the next button, it pulls in the next swf file.  I numbered the swf files so they're 1.swf, 2.swf, etc.  Everything works fine except theirs this blinking in between removing the old swf and bringing in the new.  Right now I'm having them load into an existing moveClip called "clipsMC".  I'm guessing that there's a split second where the old swf is removed and the new one loads.  I need to have them run smoothly together though, so some type of listener to make sure the new one is loaded before removing the old one?  Here's the part of the code I have for bringing it in:

function loadSwf()

{

  clipNum = clipVar + ".swf"; // creates the name of the swf file... works

  var url:URLRequest = new URLRequest(clipNum);

  removeSWF();

  myLoader.load(url);

  clipsMC.addChild(myLoader);

}

function removeSWF():void

{

  if (clipsMC.numChildren != 1)

  {

  myLoader.unloadAndStop();

  clipsMC.removeChild(myLoader);

  }

}

TOPICS
ActionScript
432
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 28, 2014 Jul 28, 2014

If you are using the Loader class, then you use the contentLoaderInfo property.  The Help documentation should provide enough info in its use.  Use of it would be pretty much along the lines of....

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, processLoadedContent);

where processLoadedContent is replaced by the name of whatever function you create as an event handler.

You could also use just one Loader object if you reparent the content of the Loader to a Sprite or Movielcip.  You cou

...
Translate
Community Beginner ,
Jul 27, 2014 Jul 27, 2014

Oh and I can't share the fla unfortunately.  It's security sensitive for a client.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 28, 2014 Jul 28, 2014

If you are using the same Loader then you will have to change that.  You need to have more than one so that you can have it where the first doesn't unload until the second is fully loaded.

As far as a listener goes, the Loader class has a contentLoaderInfo property which is essentially a LoaderInfo object which you can use to know when loading is complete.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 28, 2014 Jul 28, 2014

Do you have any links or further information on how to implement the LoaderInfo object?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 28, 2014 Jul 28, 2014
LATEST

If you are using the Loader class, then you use the contentLoaderInfo property.  The Help documentation should provide enough info in its use.  Use of it would be pretty much along the lines of....

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, processLoadedContent);

where processLoadedContent is replaced by the name of whatever function you create as an event handler.

You could also use just one Loader object if you reparent the content of the Loader to a Sprite or Movielcip.  You could keep the Loader invisible so that it only acts as a loading mechanism and not a displayed object.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines