Part 1:
Creating a LOADING movie clip
In your
loader scene, first place a static text field that says LOADING. Now press F8 to make it a movie clip and
we will just call it
loading text. Now double click on the movie clip to go inside of it.
Leave frame one as is. Now go to frame 10 and add a new key frame then in this key frame add a
. after the word loading. Do this a couple more times
spacing the frames 10 apart.
Ex:
No go back to your main time line. Create a new layer and call it "Actions" and in the first frame of the Actions layer hit F9 to go into your actions panel.
Action Script:
stop();
myInterval = setInterval(preload, 100);
function preload() {
var current = _root.getBytesLoaded();
var total = _root.getBytesTotal();
var pctLoaded = Math.round(current/total*100);
if (current >= total) {
gotoAndStop("main", 1);
clearInterval(myInterval);
}
}
Action Script Explained:
stop();
Makes it so that the file doesn't automatically jump to the
main scene.
myInterval = setInterval(preload, 100);
Here we are creating an interval for the preload function so that we can call the function again and again, and telling it that we want to call the function every 100/1000 second.
function preload() {
var current = _root.getBytesLoaded();
var total = _root.getBytesTotal();
var pctLoaded = Math.round(current/total*100);
}
Creates the function called "preload". We have to create a couple variables, one is set to be the number of bytes that are currently loaded, one is the number of total bytes that need to be loaded and the last is percentage loaded.
In order to get the pctLoaded variable, we need to do just a little basic math. So that we only get a nice rouned number with no decimal places, we need to use the Math.round command. Then the simple math is taking the variable current and dividing it by the the variable total and multiplying that by 100.
if (current >= total) {
gotoAndStop("main", 1);
clearInterval(myInterval);
}
And last but not least. We want to create an if statment saying that if the current number of bytes is greater then or equal to (you can just use == if you would like, >= is just a precautionary measure) the total bytes loaded then we will gotoAndStop on the scene labeled
main on the first frame. And last, we simply need to clear our interval so the preload function does not keep getting called again and again.
Thats all there is to making a LOADING text preloader!
preLoader1.fla
Be sure to read parts 2 and 3 also!