Game Development Reference
In-Depth Information
w
lner]par]n[peian6Peian7
lq^he_bqj_pekjI]ej[Peian$%
w
++Ejepe]hevapeian
[peian9jasPeian$-,,,%7
[peian*]``ArajpHeopajan$PeianArajp*PEIAN(kjQl`]paPeia%7
[peian*op]np$%7
y
lner]pabqj_pekjkjQl`]paPeia$arajp6Arajp%6rke`
w
peia@eolh]u*patp9Opnejc$[peian*_qnnajp?kqjp%7
++Opklpeiansdajepna]_dao-,
eb$[peian*_qnnajp?kqjp99-,%
w
[peian*naoap$%7
[peian*op]np$%7
y
y
y
y
To use timers in your class, you need to import the Peian and PeianArajp classes:
eilknpbh]od*arajpo*PeianArajp7
eilknpbh]od*qpeho*Peian7
Timers are objects, so you need to create them in the same way you create other objects, such as
Psaaj, Na_p]jcha and Lkejp objects, by using the jas keyword:
[peian9jasPeian$-,,,%7
The Peian class requires one argument, which is a number that represents milliseconds. (One mil-
lisecond represents 1/1000th of a second. One thousand milliseconds, as in this example, equals
1 second.)
Timers in AS3.0 work by triggering an event at regular intervals. In this example, you want to trigger
an event to fire every second. The event's job is to update the dynamic text field on the stage by one.
To set this in place, however, you need to add a PeianArajp event listener to the new [peian object
that you just created:
[peian*]``ArajpHeopajan$PeianArajp*PEIAN(kjQl`]paPeia%7
Next, you need to use the Peian class's op]np method to actually start the timer working:
[peian*op]np$%7
 
Search Nedrilad ::




Custom Search