Hi all,
This is my first time post here. I often come here looking for answers to my AS3 questions (I’m fairly new to scripting). Well, this one has me stumped. I’ve searched here and other places, but haven’t seen anything that corresponds to my problem.
I’ve created a preloader in Flash with AS3 only (preloader.swf). The preloader shows a white screen with percentage numbers (dynamic text) going to 100 and a percentage sign (static text). It works fine within the Flash environment (CS4), but it does nothing within either IE or FF. Here’s how it “should” work: preloader.swf loads a swf file (movie.swf). Within movie.swf is code which loads an external FLV (action.flv). All assets (preloader.swf, movie.swf, action.flv) are stored within the some folder.
If I don’t use preloader.swf in creating the HTML page within Dreamweaver CS3, and just use movie.swf, it works fine, although the area where movie.swf loads is black until the loading event completes.
If I use preloader.swf, the preloader file loads (white screen with a “%” sign, which is the static text), but the percentage numbers never appear and movie.swf never loads.
Any help would be appreciated. Please be aware that I am fairly new to AS3, so go easy on the jargon.
Here’s the code in the preloader:
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
loader.load(new URLRequest ("movie.swf"));
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}
function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(loader);
}
Thanks,
Graham