!
©!2009!DevelopmentArc!LLC,!All!rights!reserved.!
before!we!start!laying!out!our!component,!because!those!new!property!values!may!
be!required!during!the!layout!stage.!
Each!invalidation!method!has!a!corresponding!validation!method:!
invalidateProperties()!corresponds!to!commitProperties(),!invalidateSize()
corresponds!to!measure()!and!invalidateDisplayList()!corresponds!to!
updateDisplayList().!!As!we!invalidate!the!component,!the!LayoutManager!tracks!
which!invalidation!methods!have!been!called!on!the!component,!and!only!calls!the!
corresponding!validation!methods!during!the!validation!phase.!
For!example,!let’s!imagine!that!our!component!has!a!property!called!!data,!if!the!
value!does!not!affect!the!size!or!the!display!of!the!component,!then!we!would!only!
want!to!call!the!invalidateProperties()!method!during!Invalidation.!!This!means!
that!when!the!next!RENDER!event!is!dispatched,!the!LayoutManager!will!check!the!
component,!see!that!only!properties!are!invalid!and!then!call!commitProperties().
16
!
Validation!also!has!a!fourth!method,!and!as!you!can!see!in!Figure!7!‐!The!Validation!
Stages,!called!layoutChrome().!!The!layoutChrome()!method!is!not!defined!by!
UIComponent,!but!by!the!base!Container!Class.!!When!creating!a!container,!you!will!
often!want!to!create!a!border!or!padding!around!the!children!content,!which!should!
be!executed!within!this!method.!!layoutChrome()!is!executed!after!measure()!so!
that!the!children’s!dimensions!are!known!and!the!“chrome”!can!be!applied.!
Now!that!we!have!defined!the!Invalidation‐Validation!cycle!lets!look!back!to!our!
Button!component!creation!process.!!If!you!recall,!during!the!Initialization!phase!the!
children!are!created!(TextField!for!the!label)!and!then!the!childrenCreated()!
method!calls!the!three!Invalidation!methods.!!!
At!this!point,!we!now!have!a!parent!and!access!to!the!LayoutManager,!so!the!
invalidation!methods!will!register!our!new!Button!with!the!LayoutManager!for!all!
three!invalidation!methods!and!wait!until!our!next!RENDER!event!to!process!the!
changes.!!All!three!methods!are!called!because!this!is!the!first!Validation!pass!of!the!
component’s!lifecycle.!
After!the!LayoutManager!has!executed!all!the!required!validation!methods
17
!on!the!
component,!the!LayoutManager!checks!to!see!if!the!component!has!been!marked!as!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
#When#considering#validation#or der,#the#order# the#methods#are#ca lled#are#important#only# when#more#
then#one#invalidat e#method#has#been#called#during #the#invalidation#pass.##If#the#
invalidateDisplayList()#method#is#the#only#invalidation#method#called,# then#only#
updateDisplayList()#will#be#called# during#the#validation#pass.#
17
!Technical#Note:#The#de fined #validation#methods#are#all#protected#methods, #which#are#intended#to#be#
overridden#by#developers#to#provide#support#for#custom#component#creation.##These#methods#are#not#th e#
met hods#called#dir ectly#by#the#LayoutManager.##The#LayoutManager#acces ses#the#public#functions#
validateProperties(),#validateSize(),#and#validateDisplayList().##These#methods#
double#check#to#m ake#sure#the#component#is#truly#invalidated#and#han dle#other# checks#before#executing#
the# methods#descr ibed#above.##W e#focused# on#the#protected#methods#because#this#is#most#often#how#you#
create#custom#components#and#also#how#the#Adobe#documentation#ex plain s#the #validation#methods.##For#
Comentarios a estos manuales