Skip to main content
Known Participant
July 28, 2014
Answered

loading multiple swf's with addChild without blinking in between

  • July 28, 2014
  • 2 replies
  • 505 views

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);

  }

}

This topic has been closed for replies.
Correct answer Ned Murphy

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.

2 replies

Ned Murphy
Legend
July 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.

castrainAuthor
Known Participant
July 28, 2014

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

Ned Murphy
Ned MurphyCorrect answer
Legend
July 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 could keep the Loader invisible so that it only acts as a loading mechanism and not a displayed object.

castrainAuthor
Known Participant
July 28, 2014

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