Game Development Reference
In-Depth Information
The first change that you made to the program was to display the lkj`L]ca instance right away when
the storybook starts. You did that with this directive:
You made this change purely for testing purposes, so you wouldn't have to click
through to the pond page from the start page to see the effect of the new code. It just
saves a bit of time, and you can change it back to ]``?deh`$op]npL]ca% when the
storybook is finished and you're done testing the code.
The next line of code might come as a bit of a surprise:
opkl$% is a special Ikrea?hel class method that can be used by any Movie Clip object. You may recall
that earlier I described the timeline as a spool of film. The timeline was originally developed so that
Movie Clip objects could play frames sequentially to create animations. By default, a Movie Clip's
timeline is set to start playing all frames automatically when a Movie Clip object is on the stage. This
is very helpful for objects that are animated, but not if you're using the timeline to store object states,
as you're doing in this project.
The opkl method stops the timeline dead in its tracks. This is exactly what you want: the frog's time-
line to be stopped on frame 1. If you hadn't used the opkl method here, all three frames of the frog
movie clip would have flickered past in a never-ending loop on the stage.
If you ever want the Movie Clip objects to play a series of frames sequentially, you can
use the lh]u$% method. lh]u$% is very useful if you designed one of the object's states
to be a short animation that spans several frames, such as a spaceship exploding.
The next two new lines of code add event listeners to the frog:
You're adding two separate event listeners. The first one uses the IKQOA[KRAN event type, which trig-
gers the event when the mouse moves over the object. The second uses the ?HE?G even type, just like
the buttons do. You've added two event listeners instead of just one to add a little more surprise and
interest to the interactive frog.
The event handlers that are triggered by the listeners contain some new directives that you haven't
seen before. Let's first look at the kjBnkcIkqoaKran event handler:
lkj`L]ca*bnkc*naikraArajpHeopajan$IkqoaArajp*IKQOA[KRAN( ±
Search Nedrilad ::

Custom Search