This tutorial covers the making of a smooth preloading bar, bereft of that hideous jerkiness getBytesLoaded() yields as is. I'll make a concerted effort to explain why things are done, not just how. Alright, let's get down to brass tacks.
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:
That's all you need. I go into some detail as to what's happening with this code on the following page.
Featured Flash FLA
» Author: SupravisionMedia
» Title: SupraSliderBasic v.2
» Description: SupraSlider Basic AS3 Flash ComponentThe SupraSlider Basic Component represents a basic must-to-have tool for every Flash developer.The component has resizable slide bar which is based on the height of the scrolled movie clip. All the parameters in the component inspector can be accessed dynamically by code. The component has a set of public methods that give you a full control over the component.
» More by SupravisionMedia
Featured Sound Loops
Featured Flash Site
» Author: Fábio FAFERS
» Title: FAFERS Irregular Serif Font
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
» More by Fábio FAFERS