Search Tutorials
Setting up the actionsBruce Lee ain't got nothin' on thisIn the second frame of the control layer, we want this action:
loadedbytes=getBytesLoaded();
totalbytes=getBytesTotal();
loadedkbytes=Math.ceil (loadedbytes/1000);
totalkbytes=Math.ceil(totalbytes/1000);
if (loadedbytes == totalbytes) {
nextScene ();
}
frame = int(loadedbytes/(totalbytes/100));
tellTarget (_root.loader) {
gotoAndStop (_root.frame);
}
Explanation TimeFirst, we set up our variables, using getBytesLoaded() and getBytesTotal(). Note that loadedkbytes and totalkbytes use Math.ceil(), which rounds the results up to the nearest integer. When looking at KB, no one cares about the leftover fractions! (well maybe some people do, I don't know.)Next we use an if statement to see whether or not the movie is loaded. I use the "==" operator here, because it checks for true or false. If it's true, we just go to the next frame and continue on with our movie. If it's false, we continue on down the script. The next part gives us our percentage value, which also is the frame number we want our loader to go to. After figuring what percentage we are at in the loading process, we then tell the loader to go to that frame. Make it loopIn the 3rd frame, Control layer, place an action to loop back to the first frame. Simple!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|