First you have to access your Publish Settings. Go into your FLA file and press CTRL+SHIFT+F12. If this doesn’t work then you can always access the Publish Settings through File -> Publish Settings.
You should get to this window:
Now go to the Flash Tab, and you should see a button called Settings… located right next to a drop down box labeled “ActionScript 3.0″. Click on it.
You should be at this location now:
Now look at the spot that’s labeled “Export classes in frame:”. Right next to it should be a text box that by default should be 1. Change it to 2, then click Ok.
What this does is allow you to put a preloader in frame 1 and preload all your exports too. All the music/sounds/movie clips you add dynamically from the library will be loaded after frame 1 is loaded. So you can put your preloader in frame 1 and it’ll preload all exports.
Next step is to create a preloader. You can’t have the preloader be a class or have a class name or else it’ll be loaded on frame 2 also and you’ll get an error.
So create a Rectangle. Make the border, and filling a different MovieClip. Give the filling the instance name bar_mc. Then in the first frame of your project, put this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 | addEventListener(Event.ENTER_FRAME, onEnter); function onEnter(e:Event):void{ var perc:uint = new uint(); perc = this.loaderInfo.bytesLoaded/this.loaderInfo.bytesTotal*100; if(perc == 100) { removeEventListener(Event.ENTER_FRAME, onEnter); nextFrame(); }else{ bar_mc.scaleX = perc/100; } } |
Now what you’ll want to do is in your main class, create a function called init(), and have all the code that happens when the project loads in there. Then in your frame 2, put:
1 2 | init(); stop(); |
To download the FLA, click here
discuss this topic to forum
