There is a several ways to build a flash preloader for a flash movie but I guess the easiest one that wouldn't really much actionscript lines, is the one that use ProgressBar and Loader components that exist in the components library.

Of course i am not going to talk onlu about this kind of preloader , but i will try to show you the most used components that could be used in a flash movie.

1 - Component preLoader

first step we create a new flash document (Ctrl+N) and go to the Components section (Ctrl+F7) or windows > Components, we drag the loader component to the stage and resize it till i fits the size of your movie or image that you want to download, keep selecting the component in the stage and give it an instance name ex:"ploader" in the properties or parameter section.

second step , we go back to the components section and we drag the Progressbar component and we give it too and instance name ex:"proBar"







3rd step : select the Frame 1 and we go to the action panel and we add this script:




ploader.contentPath = "your_file";
proBar.source = ploader;



in th first line change the value of "your file" to the location of JPG or SWF.

Additional command that can be used in need.
ploader.autoLoad = false;
if we set autoloader property to false it means our loader won't start loading till we invoke the method
ploader.load();




2 - prLoader using actionscript







Our second flash preloader would be based on actionscript , We create a New Flash document Ctrl + N , and we create a MovieClip .

Within the MovieClip , We create the animation that we want our preloader to show while loading , Create the animation from frame 1 to frame 100, you can do any kind of animation between the frame 1 and 100 , well , in my case i used a progressbar , but in your case you could use any kind of flash preloaders(Note : Progressbar became so classic in its use and better to use an animation ) .
We add a dynamic text and we give it a var name in the var section , name it "text".







We go back to the root Movie and We Select the MovieClip we created , open the action panel and we add this script



onClipEvent (load) {
total = _root.getBytesTotal();
}
onClipEvent (enterFrame) {
loaded = _root.getBytesLoaded();
percent = int(loaded/total*100);
text = percent+"%";
this.gotoAndStop(percent);

if (loaded == total) {
gotoAndPlay(2)
}
}




select the first frame and go to the action section , add this script


stop();
go and build the rest of your movie , starting from frame 2 or whatever you like , unless you change the start in the actionscript in the action panel ,

and it's done .

here is some various companies that builds some nice preloaders:

* www.gothikamovie.com
* www.onceuponatimeinmexico.com
* www.wimbledonmovie.com/
* www.sony.com/walkman


Posted in Libellés : Publié par y. elhafyani à l'adresse 4:17 PM  

0 commentaires:

 
Copyright 2005-2008 Flash RIA .