Game Development Reference
In-Depth Information
Creating an asset holder MovieClip
We will need a movie clip to hold all of the game's library assets on frame 2 of our timeline. We
call this an
asset holder clip
. We add this clip so the preloader can accurately load all of the
bytes needed for the game's entire library without overloading frame 1. If assets are exported in
the first frame, they cannot be preloaded properly, because the
Main.as
class will not start to run
until all of the assets are loaded. This defeats the purpose of having a preloader message to the
user, because the message will not show up until the frame 1 assets have been loaded. Loading
everything before
Main
runs would cause a long delay and a blank screen for the user.
The
soundHolder
that you saw in the library previously will contain all of our sound assets for the
game. If we had graphical assets, we could either create a
graphicsHolder
clip or just add them
to the
soundHolder
clip. If you do have a combined assets clip, you might want to rename it
assetsHolder
instead of
soundHolder
. The name will not be used in code, so it is up to you how
you name the clip.
The asset holder clip (
SoundHolder
in this example) will contain all of the assets for the game that
are instantiated from the library in code. If assets are on the main timeline of your movie, or inside
another clip on main timeline, then you will not need to put them inside the
soundHolder
(or
assetsHolder
) clip. None of the games in this topic make use of too many (if any) timeline-based
assets, so all of your assets for the games so far would need to be inside an
assetsHolder
clip for
preloading purposes.
Linking the assets
There are three sounds in our library, and they should all have linkage names but will not be
exported on the first frame. The linkage names will mirror the object instantiation names we will
use in the
Main.as
class. Figure 12-4 shows an example for the
explode.mp3
library asset. Notice
that the linkage (
SoundExplode
) name and the library asset name (
explode.mp3
) are not the same.
You can change these to be the same by renaming the library asset after import.
Figure 12-4.
The linkage properties for explode.mp3
Table 12-1 shows the class names and corresponding library assets.