0

I'm sure this a simple problem and I'm overlooking something obvious.

I have an external pre-loading SWF that contains nothing but a movie clip (loader_graphic) on one layer, in the first (and only) frame; and a loading script on another layer, in the first frame. The movie clip is just a simple loop animation with no progress indicators. If I don't include the script, it works great.

The script loads the external SWF, and by itself, it works just as it should.

When I combine the two, I get the first frame of the movie clip, and then it freezes until the external SWF is fully loaded. Once it's loaded, it plays one time and stops. I'm somewhat new to AS3, and I know that preloading is one of the conventions that has changed, so I probably don't have it coded properly:

loader_graphic.play();

import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.ProgressEvent;


var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("external.swf"));

function loop(e:ProgressEvent):void
{
  var perc:Number = e.bytesLoaded / e.bytesTotal;
}


function done(e:Event):void
{
  loader_graphic.stop();
  addChild(l);
}

Any help is appreciated.

Ty Morton
  • 733
  • 2
  • 8
  • 29
  • This may not be related, but make sure that no scripts in external.swf refer to the stage, as the stage property will be null until the loading movie adds it with addChild(). Put something like this in the constructor of external.swf: `addEventListener(Event.ADDED_TO_STAGE, init);` and don't refer to the stage until after init() is called. – null Oct 21 '12 at 00:00

1 Answers1

0

It turns out that the preloader was playing all along. It was just stalled because the main SWF was overloading the Flash player.

The main SWF it was loading included an F4V video being streamed from a standard web server, and it was too much for the player to handle all at once. I embedded the video, instead, and it all worked perfectly.

Ty Morton
  • 733
  • 2
  • 8
  • 29