Hellos!
I am making an “interface” which loads an external swf file onto ths stage and plays it from there. I have a preloader which is supposed to “colour” a logo while the flash loads(using a mask which is scaled to the loaded % of the file).
My problem is that it doesn’t do anything until the whole external file is loaded. Then, the preloader flashes once and the content is played. I have no idea what I’m doing wrong, and it’s driving me insane!
Here’s my code:
import flash.events.Event;
stop();
/*******************load flash from external file*************** */
try
{
var bLoaded:Number = 0; // current number of bytes loaded
var bTotal:Number = 0; // total size of file
var percentageLoaded:Number = 0;
Security.allowDomain("http://www.magicstorybox.co.nz");
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("http://www.magicstorybox.co.nz/Characters/charYe.swf");
myLoader.load(url);
// to get the load progress
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedHandler);
stage.addEventListener(Event.ACTIVATE, startPreloader);
}
catch (e:Error)
{
trace(e.message);
}
function startPreloader(event:Event):void
{
var percentageLoaded:Number = bLoaded/bTotal;
trace("Preloader started");
mcMask.scaleY = percentageLoaded;
}
function loadedHandler(event:Event):void
{
trace("loading complete!");
stop();
gotoAndPlay(1, "content");
}
function loadProgress(e:ProgressEvent):void
{
trace("loading. . .!");
bLoaded = e.bytesLoaded;
bTotal = e.bytesTotal;
trace("Loaded = " + bLoaded + "/" + bTotal);
}
I may be looking at this the wrong way, but it’s the first time I’m trying to load an external .swf file into another .swf :3
Any help would be hugely appreciated!
Thanks!
-Nazgul