Game Development Reference
In-Depth Information
y
lner]pabqj_pekjkjAjpanBn]ia$arajp6Arajp%6rke`
w
++@ena_perao***
y
y
y
All the classes follow this same basic structure. Figure 8-14 explains how all these pieces fit together.
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*arajpo*Arajp7
lq^he__h]ooC]iaK^fa_patpaj`oIkrea?hel
w
lq^he_bqj_pekjC]iaK^fa_p$%
w
]``ArajpHeopajan$Arajp*=@@A@[PK[OP=CA(kj=``a`PkOp]ca%7
y
lner]pabqj_pekjkj=``a`PkOp]ca$arajp6Arajp%6rke`
w
++Ejepe]hevalnklanpeao
++=``arajpheopajano
]``ArajpHeopajan$Arajp*AJPAN[BN=IA(kjAjpanBn]ia%7
]``ArajpHeopajan$Arajp*NAIKRA@[BNKI[OP=CA(kjNaikra`BnkiOp]ca%7
y
lner]pabqj_pekjkjNaikra`BnkiOp]ca$arajp6Arajp%6rke`
w
naikraArajpHeopajan$Arajp*AJPAN[BN=IA(kjAjpanBn]ia%7
naikraArajpHeopajan$Arajp*=@@A@[PK[OP=CA(kj=``a`PkOp]ca%7
naikraArajpHeopajan$Arajp*NAIKRA@[BNKI[OP=CA(kjNaikra`BnkiOp]ca%7
y
lner]pabqj_pekjkjAjpanBn]ia$arajp6Arajp%6rke`
w
++@ena_peraoƅ
y
y
y
When the object's constructor
method runs, a listener waits for
the object to be added to the stage.
When the object has been added
to the stage, its properties can be
initialized and other listeners
can be added.
When the object is removed from the
stage, its listeners are also removed.
ENTER_FRAME events should always
be removed so that they don't continue
to run in the background. Other event
listeners also need to be removed
so that the object can be completely
cleared from the Flash player's memory.
Any other tasks that you want the object
to perform when it's removed can also
be included here.
Figure 8-14. Using the ADDED_TO_STAGE and REMOVED_FROM_STAGE event listeners
Optionally, to make sure that an object isn't reinitialized if it's accidentally added to
the stage again, remove the =@@A@[PK[OP=CA event listener in the kj=``a`PkOp]ca
event handler itself:
lner]pabqj_pekjkj=``a`PkOp]ca$arajp6Arajp%6rke`
w
]``ArajpHeopajan$Arajp*AJPAN[BN=IA(kjAjpanBn]ia%7
]``ArajpHeopajan$Arajp*NAIKRA@[BNKI[OP=CA(kjNaikra`BnkiOp]ca%7
naikraArajpHeopajan$Arajp*=@@A@[PK[OP=CA(kj=``a`PkOp]ca%7
y
 
Search Nedrilad ::




Custom Search