How to preload the main movie with levels all at the same.
Step 1
Put a stop(); action in the first Keyframe of the movie(s) being loaded and nothing else. No movie clip, no graphic, no music or picture but just an empty Keyframe and a stop(); action. Then you load the movies you want. You can load all the movies at once or just a few.
Step 2
This is the code to preload the movie(s), put this code on your preloader:
onClipEvent (load) {
// Load Three movies
loadMovieNum (“Music.swf”, 1);
loadMovieNum (“Music.swf”, 2);
loadMovieNum (“Music.swf”, 3);
}
onClipEvent (enterFrame) {
// We devide it by 1000 to get rid of the decimal numbers
Total = Math.floor(_level1.getBytesTotal()/1000)+(_level2.getBytesTotal()/1000)+(_level3.getBytesTotal()/1000)+(_root.getBytesTotal()/1000);
Loaded = Math.floor(_level1.getBytesLoaded()/1000)+(_level2.getBytesLoaded()/1000)+(_level3.getBytesLoaded()/1000)+(_root.getBytesLoaded()/1000);
Percent = Math.floor((Loaded/Total)*100);
_root.PercentDisplayTwo = int(Loaded)+” KB “+” | “+(Total)+” KB”+” | “+(Percent)+” %”;
if (Percent == 100) {
// Have a frame lable inside the loaded movie so you can park it
// and call it when ever you want
_level1.gotoAndStop(“One”);
_level2.gotoAndStop(“One”);
_level3.gotoAndStop(“One”);
_root.play();
}
}
drag the loader component to frame 1 of the “preloader” layer .
Place the content on frame 2 of the main content layer and applied a “stop” action to it .
Step 1
After completing the installation of the Extension Manager, and successfully setting up the .mpx loader file, we should be able to see the loader component from the drop-down menu of the Components (Go to Windows> Components, or press ctrl F7)
Fig 1
And that’s our “percentage preloader” component.
Step 2
We will create two layers as shown in Fig 2 .
Fig 2.
Select the first frame of the “preloader” layer and drag the loader component to the stage.
Select the second frame of the “Main Content” layer and place your content there.
Right-click on that keyframe and go to Actions, and add stop(); (You don’t want your movie to go in loop back to your preloader).
For testing:
(Go to Control>Test Movie)
Make sure you select “show streaming” in order to see the preloader in action.
Note: If you want to change the preloader text color go On the Actions layer of the loader component, modify the following action on line 31 :
Today if your flash exceed 700 KB (the size of a larger picture), is if you put a Preloader.
Actionscript 3 is very simple in the first frame put the code
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onProgress(e:ProgressEvent):void{
var loaded:Number = e.target.bytesLoaded;
var total:Number = e.target.bytesTotal;
var pct:Number = loaded/total;
loaderMc.barMc.scaleX = pct;
}
function onComplete(e:Event){
play();
}
Where “loaderMc is a MovieClip that contains another MovieClip” barMc. To make things interesting, “barMc” you put on a mask layer in which you can draw like you want to show your progress bar.