Open a new .fla and draw yourself a rectangle. You could, of course, dynamically create this with this.createEmptyMovieClip(), subsequently using Flash's drawing API to display your bar, but why? You're in the authoring tool, you might as well skip the 6 lines of actionscript and just draw the freaking rectangle. Alright Picasso, down with the brush. Make this a MovieClip- name it as you like.
Inside said MovieClip's timeline, name the layer assets, or whatever works for you. Convention says we keep a container for our rectangle, such that the loading bar is a sensical display of our loading progress. But convention leads to aesthetic stagnation. All the same we'll leave the stroke around the rectangle. Select the bar (not the stroke) and make it a MovieClip... for organization's sake call it lb, & set the clip's registration to the left.
Now create a new layer and name it scripts. Enter the following actionscript:
_root.stop();
var percLoaded:Number=0; var newPercLoaded:Number;
onEnterFrame = preload;
function preload():Void { newPercLoaded = Math.floor(_root.getBytesLoaded()/_root.getBytesTotal()*100); lb._xscale=percLoaded=percLoaded+(newPercLoaded-percLoaded)*.2; if(percLoaded>99.9&&newPercLoaded==100){ stop(); _root.nextFrame(); delete this.onEnterFrame; } }
That's all you need. I go into some detail as to what's happening with this code on the following page.
| » Level Basic |
|
|
Added: : 2005-03-08
Rating: 6.31 Votes: 32
Hits: 2260
|
| » Author |
|
black is the new black
|
| » Download |
|
Download the files used in this tutorial.
|
|
Download (0 kb)
|
|
Get conversion and unzipping tools
for PC and Mac here!
|
| » Forums |
|
More help? Search our boards for quick answers!
|
|
Please rate this tutorial, 10 is the top rating, you can also click the
comments link to read/write a review.
|
|
|
|