I've been working on a little flash app for the last couple of months and now the final hurdle is strapping a preloader on to the front of it.
The app is a fla/swf controlled by a Main.as document class written in AS3.
I originally wrote it in CS3 but after hitting my head against a wall for several days trying to figure out how to add a preloader I upgraded to CS5 in the hopes it would be easier. Several webpages (eg http://www.flashconf.com/category/flash-cs5/) mention being able to just specify a preloader.swf in the actionscript settings. I've tried adding mine but it doesn't appear to do anything when I simulate download or check it online. Should it really be that easy or am I misunderstanding. There's a surprising lack of info about for CS5.
The other option is to add one into the actual app swf, which I did find a guide for (http://active.tutsplus.com/tutorials...ngle-swf-file/) ...but its for CS3/4. I'm willing to give it a go as a last resort, but I wanted to check to see if there's an easier way for CS5.
Any help would be much appreciated, thanks!
Last edited by CartoonizeMyPet; 09-22-2010 at 05:05 PM.
Go to Publish settings - Flash - Actionscript 3 settings. In the bottom you see Preloader method. Set it to preloader.swf. Then a preloader is automatically added in form of little moving dots. Another possibility is to use Flex and load your Flash movie into Flex. Flex adds a preloader automatically.
- The right of the People to create Flash movies shall not be infringed. -
I did but all I got was 107s of white screen before it loads.
I also tried adding a big image into a fresh as3 fla and testing it on 56kb too. Again just a white screen until it fully loads.
The default path for the preloader.swf in a fresh fla is:
$(AppConfig)/ActionScript 3.0/rsls/loader_animation.swf
I searched my computer for loader_animation.swf and couldn't find it. Maybe I'm missing it from the download? Although that wouldn't explain why it doesn't seem to appear when I link to my own preloader.swf.
I'll try releasing it to a few friends and see if the ones with slower connections see it.
Ah so that's where it's hiding! I'm not sure why my computer didn't find it before. There is a loader_animation.fla and swf there already. This is bizarre.
So when you open a new fla, put a large image in it and do
Control > Test Movie > In Flash Prof
it does show the little dots when simulating the download?
I could be wrong, but aren't those options in Publish Settings only applicable to Runtime Shared Libraries and not to the main movie itself?
If you're just trying to preload your swf file, here's a quick and dirty version of a preloader, assuming a text field called loadDisplay is on frame 1 and everything else happens on frame 2 or later. If that's not the case, you could have the "complete" event trigger a init() function or the like:
Code:
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
this.loaderInfo.addEventListener(Event.COMPLETE,doneLoading);
function showProgress(evt) {
stop();
var percentLoad=Math.round((evt.bytesLoaded/evt.bytesTotal)*100);
loadDisplay.text=percentLoad+"%";
}
function doneLoading(evt){
play();
this.loaderInfo.removeEventListener(Event.COMPLETE,doneLoading);
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS,showProgress);
}
Aha! I wondered what all that "Runtime Shared Library" stuff was about! Why the heck don't Adobe just make it so we have automatic preloaders for every movie?!
Thanks for the code! I'll see if I can work something out with it. Unfortunately I'm using an external document class, which always seems to make preloaders that much harder to implement. At least now I know the "automatic" one in CS5 isn't so automatic, so I can concentrate on tracking down a solution.