Game Development Reference
Both `kknKja and `kknPsk are instances of the @kkn class, so they both share this code. The code
is general; it doesn't make any reference to any other object and doesn't get involved in the game
logic—it's very well encapsulated. You can see here how the class attempts to be a model of a real
door. Real doors can be either opened or closed, and they also make sounds. You should be able to
use this code equally well with any other door objects in the game you might create, and it will work
In this game, both `kknKja and `kknPsk are instances of the same class, so it's easy for
them to share the same code. What would you do, however, if you had two different
symbols that needed to share the same class?
In the Symbol Properties , assign each symbol a unique class in the Class field, such as
AjaiuKja and AjaiuPsk . Just below the Class field is a field called Base Class . In the
Base Class field, assign the common class that you want them to share (for example,
?kiikjAjaiu?h]oo ). You can then control instances of both symbols using this one class.
Next, I'll show you how to play a sound when the doors open.
Adding sound to the game
To use sound in a game, you need to import the sound file into the Library . Here's how to add the
chime sound of the door opening to Dungeon Maze Adventure:
1. Open the game's FLA file.
2. Select File ° Import ° Import to Library .
3. Find the sound file you want to use and click the Import to Library button. The sound will now
appear as a symbol in the Library .
4. Select the sound in the Library by clicking it once. Click the Properties button at the bottom of
the Library pane. The Sound Properties window opens.
5. In the Sound Properties window, change the name of the sound so that it doesn't include the
file extension. For example, if the sound is called Chimes.mp3 , change it so that it's named
6. Select Export for ActionScript .
7. Change the name in the Class field so that it matches the name you gave it previously, such as
Chimes . Figure 8-20 shows what the Sound Properties of the Chimes sound in Dungeon Maze
Adventure looks like.
Any classes that use sounds need to also import the Okqj` and Okqj`?d]jjah classes: