Thursday, December 17, 2009

Preloader in AS 2.0 / Preloader in flash

If you want to place a Preloader in a frame before the actual Flash application or in a previous Scene, this is a really simple. In this tutorial I will show you the basic code for a preloader.
Step 1) First off all, create a new actionscript 2.0 file.
Step 2) Now we will create our preloader ‘graphic’ ,so create a movie clip and set instance name “preloader_mc”.
Step 3) Select a layer and draw a box(only boundary) on “preloader_mc” at the first frame, press F6 at 100 frame.
Step 4) Select another layer and draw a box and set it the left side where your boundary box is started on “preloader_mc” at the first frame.
Step 6) create tween and animate to your box at 100 frame.
Step 7) On “preloader_mc” at 1st frame and 100 frame write
Stop();
Step 8) Place “preloader_mc” on to the stage.
Step 9) write code at 1st frame on stage and then place your flash application on 2nd frame.

stop();
onEnterFrame = function () {
if (_root.getBytesLoaded() == _root.getBytesTotal()) {
delete onEnterFrame;
_root.play();
}
else
{
var frame = Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100)
preloader_mc.loading.gotoAndStop(frame);
}
};

Hit CTRL + Enter to watch your preloader in action. Remember you will not see anything happen unless you simulate a download, and of course have something for the flash to load!

No comments:

Post a Comment