Making a preloader in flash is very simple. By using ProgressBar and Image Loader components, we can have a basic flash preloader in minutes.
Hmm, if you have not opened flash yet, just open it and create a new Flash document, in property panel (Ctrl+F3) just give the size of the document as you needed. After that open the Component panel if it’s not opened (Ctrl+F7 or Windows > Components). Drag the Loader component to the stage. In the Properties Inspector panel (Ctrl+F3 or Window > Properties) and adjust the size of the Loader to your requirement for loading <strong>Image</strong>. for that, give it an Instance Name of <strong>imgLoader</strong>. Now go back to your Component panel and drag the Progressbar component to the stage. In the Properties Inspector panel (Ctrl+F3) give it an Instance Name as <strong>progBar</strong>.
Now for the Actionscript to write. Select Frame 1 of the main timeline and bring up the Actions panel (press F9). Copy and paste the below code:
imgLoader.contentPath = "file_name"; //filename of the image (or) path of the image file progBar.source = imgLoader;
You guys! can also change the label of the progress bar even color of the progress bar. This property is a string in the format “%1 out of %2 loaded (%3%%)”; %1 is a placeholder for the current bytes loaded, %2 is a placeholder for the total bytes loaded, and %3 is a placeholder for the percent of content loaded. The characters “%%” are a placeholder for the “%” character. If a value for %2 is unknown, it is replaced by “??”. If a value is undefined, the label doesn’t display. The default value is “LOADING %3%%”
By adding the above string format, now our code look like this:
imgLoader.contentPath = "file_name"; //filename of the image (or) path of the image file progBar.label = "%1 out of %2 loaded (%3%%)" progBar.source = imgLoader;
by default it will display our loaded files in Kilobytes (KB), we can change it by adding this line progBar.conversion=1024;
So our code will look like this:
imgLoader.contentPath = "file_name"; //filename of the image (or) path of the image file progBar.label = "%1 out of %2 loaded (%3%%)" progBar.conversion = 1024; progBar.source = imgLoader;
If you want to change progress bar color, then add the below code
progBar.setStyle("themeColor", "0xEEEEEE");If you want to change the label color of the progress bar, then add the below code
pBar.setStyle("color", "0xFFFFFF");imgLoader.contentPath ="file_name"; //filename of the image (or) path of the image file
progBar.setStyle("themeColor", "0xEEEEEE");
progBar.setStyle("color", "0xFFFFFF");
progBar.label = "%1 out of %2 loaded (%3%%)";
progBar.conversion = 1024;
progBar.source = loader;Once particular file has been loaded, if you want to hide the preloader then need to set the visibility to false – setVisible(false),
This one we need to add to the progress bar. Click on your progress bar to select it, bring up the Actions panel window and add the following code:
on (complete) {
this.setVisible(false);
}Now check your application, by pressing ctrl + Enter Key. Enjoy!!!
Related Entries...
John Resig, has explained us a better and interesting way of Method Overloading. Here he has discusse ...
AIR is rocking in the web world, if you guys! Search for Adobe AIR you will get tons of web snippets ...
Hey folks, hmmm... How can I start.... !!! Yeah, well folks... below is very simple snippet code for ...
The Sprite class is new in ActionScript 3.0, This class is a basic display list building block, which ...
Hi Dev Folks, this topic explains you about different patterns used to match character combinations i ...
I am back again with some helpful snippet code. Here using JavaScript we can pro actively sort date f ...
You guys might know the importance of XML, XML (Extensible Markup Language) is a flexible markup lang ...
Hi Guys, I would like to share a JavaScript snippet code which will remove special characters (like ! ...
Below is the code which is written in JavaScript, we can use this script for bookmarking the particul ...
To start with, Well I think bunch of developers might have come across this situations where in which ...























One Response
Hi Vivek..
u guessed mite ME from my id…anyways..very good site..im totally impressed tht my frnd could reach upto extreme heights..absoultely hats off to U….
to good tutorials and ur articles lists to motivate lot…very good
anyways meet u in office
take care
cheers
amita