!
©!2009!DevelopmentArc!LLC,!All!rights!reserved.!
(such!as!other!object!pointing!the!component,!event!listeners!with!strong!reference!
set,!etc.)!the!component!is!then!marked!for!garbage!collection.!
Finally,!the!childRemoved()!method!is!called!removing!references!to!the!
components!parent!and!document!properties.!!This!enables!the!component!to!be!re‐
parented!if!required!and!also!prevents!the!component!from!entering!the!
Invalidation‐Validation!cycle.!
At!this!point,!the!component!is!in!its!final!phase.!!If!there!are!no!other!references!to!
the!component!then!it!will!be!garbage!collected!and!deleted!from!memory.!!If!the!
component!is!garbage!collected,!then!all!its!children!are!also!garbage!collected.!!This!
leads!back!to!our!earlier!comment!about!how!removal!may!not!occur!directly!via!
removeChild().!!!
If!the!parent,!grandparent!or!any!parent!up!the!hierarchy!is!removed!and!there!are!
no!references!to!any!of!the!components!(children!or!otherwise)!in!the!removed!
component!hierarchy,!then!all!the!components!will!be!garbage!collected.!
For!example,!we!have!an!HBox!with!our!Button!as!a!child.!!If!we!remove!the!HBox!
from!the!display!stack!then!the!HBox!enters!the!Removal!Phase.!!During!this!process!
the!HBox!does!not!remove!any!of!its!children!nor!do!any!of!its!children!enter!the!
Removal!phase.!!Yet,!if!the!HBox!and!our!Button!do!not!have!any!references!to!them!
(outside!of!the!parent/child!relationship)!then!both!components!will!be!garbage!
collected!when!the!time!comes.
20
!
A+Flex+Application+ Is+Born+
Now!that!we!have!a!better!understanding!of!the!Component!Lifecycle,!we!can!begin!
looking!at!the!Flex!Application!Lifecycle.!!The!Flex!Application!Lifecycle!is!similar!to!
the!Component!Lifecycle!(stages,!phases,!etc.),!but!has!some!very!important!
additions!and!modifications!to!provide!support!for!managing!a!complete!
application.!We!have!broken!down!the!Application!lifecycle!into!the!following!
phases:!Construction,!Initialization,!Preloading,!Child!Creation,!Child!Display,!and!
Destruction.!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20
#For#more#details#on#the#AV M2#Garbage#Collec tion#(GC)#process#w e#highly#r ecommen d#rev iewing#Gr ant#
Skinner’s#excellent#articles#on#how#GC#is#processed#and#execu ted#in#the #Flash#Pla yer.#Understanding#the#
overall#GC#process#will#help#clarify#the#parent/child# relat ionship#fo r#the#Removal#phase#and#also#can#be#
applied#t o#Best#Practices#when#develo ping#custom#components.##
##
http://www.gskinner.c om/blog/ archives/2006/06/as3_ resource_ma.html #
#
Kommentare zu diesen Handbüchern