Super Easy AS3 Preloading - JUST LIKE AS2 :O!!!!!!!

Summary and Recap of a common AS2 Method
Jesse Nicholson
I'm a flash developer in Ontario Canada, I run my own business and I love pushing the limits of flash and exploring the latest developments from Adobe. I have developed a way to author flash 10 in the flash CS3 IDE and would like to begin posting articles on working with the new features (specifically 3d).
View all articles by Jesse NicholsonOne extremely simply method used to preload in Actionscript 2 is to create a preloader Scene, make it the first scene, and add 3 frames, a progress bar and a text field. There is little bits of code placed on each frame to process the loading of the movie. On the first frame there is code to manage displaying the progress in the text field and on the progress bar. In Actionscript 2 this code would be:
var progressNum:Number = this.getBytesLoaded() / this.getBytesTotal;
myTextField.text = "Loading: " + Math.round(progressNum * 100);
myCustomProgressBar.width = progressNum * (a number representing the full width you want at 100%);
Simple enough. On the next frame you would simply have the following code to determine if the movie is ready to be shown yet:
if(this.getBytesLoaded() == this.getBytesTotal()){
gotoAndPlay(3);
}else{
gotoAndPlay(1);
}
Then on the third frame we would simply reserve this space to show some sort of quick animation or show an indication that the loading is complete and the movie/site is about to be displayed, before proceeding to the actual main scene. If you wish to just jump to the main scene you would simply place on this frame:
gotoAndPlay("Scene 1 Name", 1);
So, if you're familiar with Actionscript 2 you should know exactly what's going on here and you're only issue should be wanting to punch whoever made Actionscript 3 in the face for taking this sweet little method away from you and making it SUPER complex....... or did they?


