It's customary to include a progress indicator for large SWF files.
(500K is a relatively large SWF)
A good way to do this is to create a parent SWF that has nothing in it but an empty loader object connected to a simple preloader script, and a progress indicator on the stage; your main content SWF is loaded into this loader object from an external directory on the server.
The external SWF files could also have their own loader objects and scripts as well.
You could literally have dozens or even hundreds of content SWFs stored on the server without the download/memory/stability problems associated with bloated single SWF solutions.
This is an ideal way to construct Flash applications for distribution over the internet, since the speed of the client internet connection becomes less of a factor in terms of delivering a large amount of content spread across several sections of a Flash website.
Imagine a single SWF file that has
dozenss of images embedded in a gallery, an interface, a contact form, and several text pages; the filesize would quickly become far too large for practical internet delivery, and the FLA would be a nightmare to edit.
Here's an example script that fades-in a progress indicator, which runs until the file is fully loaded, then fades-out the progress indicator, then fades-in the loaded content.
Paste the script into frame1 of a new FLA with the same dimensions as your main SWF.
(named "main.swf" in this example)
The TweenLite class is used here for smooth alpha transitions for the preloader and loaded SWF.
Download the
TweenGroup class and place the gs directory in the directory as your FLA. (the download includes, TweenLite, TweenGroup, TweenMax, some useful utilities, and some good easing classes)
The progress indicator is an empty Dynamic TextField with fonts embedded, wrapped in a MovieClip on the stage: "preloader.preloadText"
Compile the loader.swf and embed it in your HTML page.
PHP:
import gs.*;
import gs.easing.*;
/*---------------------------------------------------------------------------------*/
TweenLite.to(preloader, 0, {autoAlpha:0});
var mainLoader:Loader = new Loader();
mainLoader.x = 0;
mainLoader.y = 0;
mainLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
mainLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
mainLoader.load(new URLRequest("main.swf"));// this loads your content SWF
/*---------------------------------------------------------------------------------*/
function onProgress(e:ProgressEvent):void
{
TweenLite.to(preloader, .4, {autoAlpha:1});
var percentage:Number = e.bytesLoaded / e.bytesTotal;
preloader.preloadText.text = Math.ceil(percentage * 100).toString() + "%";
}
/*---------------------------------------------------------------------------------*/
function onLoaded(e:Event):void
{
TweenLite.to(preloader, .2, {autoAlpha:0, onComplete:loadMain});
}
/*---------------------------------------------------------------------------------*/
function loadMain():void
{
removeChild(preloader);
preloader = null;
addChild(mainLoader);
TweenLite.from(mainLoader, .2, {alpha:0});
}
/*---------------------------------------------------------------------------------*/