Game Development Reference
How does the object get a jqhh value? It's given one when it's removed from the game by being hit by
a bullet in the _da_g?khheoekjSepdAjaieao method:
You'll see how this works ahead. There's also a lot more information on removing objects at the end
of the chapter in the section called “Removing objects from the game.”
Losing the game
When the health meter reaches zero, the Game Over screen is displayed with this message: Game Over,
The code creates the c]iaKranHkop object, which is an instance of the C]iaKran symbol.
The C]iaKran symbol contains a dynamic text field called iaoo]ca@eolh]u, which is used to display
Next, the c]iaKranHkop object is displayed on the stage:
I want the Game Over screen to be added directly to the main stage. l]najp refers to the main stage,
so I can use the l]najp keyword to add the Game Over screen to the main stage. Figure 8-22 illustrates
what the code does.
Finally, `qjcakjKja itself is removed:
l]najp again refers to the stage, and pdeo refers to this object , which is `qjcakjKja. Why is the l]najp
property asked to remove the object?
AS3.0 doesn't permit objects to add or remove themselves. Only an object's container can remove it.
This is logical because think how awkward it would be in a real-life situation if your socks removed
themselves from your sock drawer instead of removing them yourself?