Game Development Reference
Oh if it were it so simple! naikra?deh`$% holds a dark secret. Even though it removes
instances from the stage, those objects still exist as objects in the Flash Player memory.
This is both a good and bad thing. It's good because if you want display the object
using ]``?deh`$% again at some later point in the program, you don't have to go to
all the trouble of creating a new instance of it using the jas keyword. It's bad because
objects that aren't visible still consume some Flash Player resources.
If you're certain that you won't need an instance in the program again, you have to
give the variable that holds a reference to that instance the value of jqhh (a special
value that means “has no value”).
To give a variable a jqhh value, use a directive that looks like this:
For more information on how to completely clear an object from Flash's memory,
check out the section on garbage collection in Chapter 8.
Using the onPondButtonClick event handler
Before the chapter ends, have a quick look at the kjLkj`>qppkj?he_g event handler:
It's identical to the kjDehh>qppkj?he_g method, except for one of its directives:
Instead of displaying the dehhL]ca instance, it displays lkj`L]ca. Pretty easy, no?
Adding back buttons
That last thing you'll do is create buttons that take you back to the op]npL]ca. There are no new
techniques here, so you can think of this as a good test to see whether you've been paying attention
to what has been covered so far. I'm also going to keep the details pretty brief, so if you're not entirely
sure about one of the steps, refer to the section in Chapter 2 on making buttons to clarify any uncer-
tainties. (The final program is in the chapter's source files under the Bejeoda` storybook folder if you
want to take a closer look.) Follow these steps:
1. In the interactive Opknu^kkg*bh] file, right-click one of the buttons in the Library and chose
Duplicate from the Option menu.
2. The Duplicate Symbol dialog box opens. Give the button the name BackToStartButton .
3. Click OK .