Now you need to move your blue mask to the left till the right side of it touch the right side of your preloader graphic but without overlapping it (leave your finger on SHIFT and press the LEFT ARROW to move it quicker) (fig7)
fig7
(image reduced in size)
Now right click on the layer called mask and from the context menu choose Mask. You will notice that the icon representing the layer change into a blue mask icon and that the icon of the layer below it change into a blue masked icon. (fig8)
fig8
Now if you go back to the main timeline
you will notice that our preloader is just represented by an empty rectangular stroke with no fill color (fig9).
fig9
Select the preloader and in the property panel and give the name preloader to the instance.
Select the first frame of the assets layer and under the preloader create a little dynamic text field and name it percentageLoaded, next to it create a static text field with the text % loaded in it (fig9a).
fig9a
fig10 For the sake of the demonstration we will be adding a Adobe UI component and a bitmap in our Flash file. Select the second keyframe of the layer assets and from the components panel drag a combo box instance on the stage, doing that will add a nice fat 55KB to the file and will give a bit of work to our preloader. Then go to File > Import > Import To Stage and browse to a bitmap image that is on your computer or use the default one provided in the source file for the tutorial (53KB image).
We have completed the first step, we have created our preloader and added some assets to our Flash file, let's move to the second step, the code.
4. We are going to have a look at 2 possible valid codes that could be use to keep track of the data loaded into the Flash player : The first implementation will use the onEnterFrame event the second one will use the setInterval method. What are the cons and the pros for each methods ? well it all depends on what you want to do really. setInterval coupled with updateAfterEvent (see our tutorial on updateAfterEvent) is particularly useful to create smooth animation because it is not dependent on the movie frame rate but can be quite CPU consuming. onEnterFrame is totally dependant on the frame rate but is less CPU dependant. Let's first examine our first implementation using the setInterval() method, copy and paste the following code on the first frame of your actionscript layer:
stop(); var initX:Number = _root.preloader.mask._x; myInterval = setInterval(checkLoading, 50, this); function checkLoading(path) { |
Continue to next page ...