Search Tutorials
Following these easy steps you will be able to have a great looking and smooth moving preloader bar in just a few minutes. Step 1 In your movie, create a new movie object and call it "loadbar". In the object create two layers. On the first (bottom) layer, create a thin (or wide) rectangular shape forming a load bar. Position it at coordinates x:0 y:0. The height of the bar can be anything you want, but make sure the width reflects multiples of 100 (100px, 200px and so on). 100px should be enough for a nice thin stylish bar. You can have the bar be any width, and you can experiment with that on your own once you complete this turotial and have a clear understanding of the math involved. This bar can be any color you like as it is the place-holder for the moving progress bar which will fill this space as the movie loads. My suggestion is to have a crisp outline of the bar with space inside allocated for the moving progress. You dont have to convert this shape to an object, so lets just call it placeholder in the rest of the tutorial. Now, on the second layer, create another rectangle so that when you position it on top of the placeholder, it forms your complete progress bar as it should appear when 100% of the movie is loaded. Make sure to convert this shape into a movie. Call it "progressbar". Se the width of progressbar to 0 via it's movie properties. Now you have a movie which contains just one frame with 2 layers. The bottom layer has the placeholder rectangle and the top layer the progressbar movie. Step 2 Make sure that the first 2 frames of your main movie are completely empty on all layers. Create 2 new layers and call them "scripts" and "preload". Take the movie object (loadbar) and place it on the very first frame (make it a key frame) of the "preload" layer. Now create a key frame on the first frame of the "scripts" layer, go to the actions of that first frame and enter the following code: _root.loading = getBytesLoaded(); _root.total = getBytesTotal(); _root.incremented = 1; If you made the width of the placeholder shape 100, leave incremented = 1, otherwise change it to reflect the width of your placeholder shape (2 if it is 200, 3 if 300 and so on). Now create a key frame on the second frame of your movie in the "scripts" layer (this frame should be empty on all layers up till now) and add the following code to its actions: _root.loadbar.progressbar._width=((Math.round(_root.loading/_root.total*100))*_root.incremented); if (_root.loading<_root.total) gotoAndPlay(_currentframe-1); Now go the the "preload" layer and add a frame to it so that you have 2 frames taken by the loadbar movie on that layer. Make sure that this layer only has 2 frames and does not continue any further. Make sure that the "scripts" layer has the 3rd frame as a key frame with no code in it (or whatever code you decide to have there, except for the code we just added to the first and second frames). Its a good idea to use this "scripts" layer for whatever code you will end up having in the rest of your movie. What you should have now in your movie is the following: First 2 frames are taken by the script code we just added and the loadbar movie on their respective layers. All other layers of the movie (if you have any other layers) are completely empty of any code on the first 2 frames. They may contain objects as you may want something to appear on the loading screen besides the progress bar (like text for example), just make sure that you understand that the first 2 frames will keep on looping until the movie is loaded 100% at which point the movie will continue onto frame 3 and so on. The following frames (starting from frame 3) are wharever you decide to have in your movie. Now you can play with the colors of the bar and the code if you like. What you have is a smooth progress bar which truly reflect the loading progress of your movie. There is another way of making a bar like this. The other way is to use masks and it is used to have more complex progress animation. I will post a turorial on it soon. Have fun and enjoy your new loading progress bar.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|