Game Development Reference
In-Depth Information
In the example in this section, you attached the event listener directly to the op]ca
object. In the interactive storybook project, you'll attach the listeners to buttons. If you
use ]``ArajpHeopajan without specifically attaching it to an object, the listener will
attach itself directly to the class that it was called in. You'll see many examples of this
in action when you start working with multiple classes in Chapter 8.
Programming storybook buttons
Now that you know about dot notation, methods, and event listeners, you can use them to help you
program the buttons in the storybook. Follow these steps:
1. Make sure that the ejpan]_peraOpknu^kkg project is open. Double-click the interactiveStorybook
Main.as file in the project window to open it in the ActionScript editor window.
2. You need to add an eilknp directive to load AS3.0's IkqoaArajp class into the program. Add
the following new code in bold:
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*arajpo*IkqoaArajp7
lq^he__h]ooI]ejatpaj`oIkrea?hel
w
r]nop]npL]ca6Op]npL]ca7
lq^he_bqj_pekjI]ej$%
w
op]npL]ca9jasOp]npL]ca$%7
]``?deh`$op]npL]ca%7
y
y
y
From now on, follow the convention that new code to add to the program will be
highlighted with bold text.
3. Next, you need to create variables to hold references to instances of the DehhL]ca and Lkj`L]ca
symbols. This is exactly the same process you followed to create the op]npL]ca instance. The
only difference is that you don't need to use ]``?deh` to display them on the stage. You want
to create them in AS3.0's memory so that they can be used later. (It's like keeping a jar of sugar
stored in the cupboard to that it's ready to use when the aunties come.)
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*arajpo*IkqoaArajp7
 
Search Nedrilad ::




Custom Search