MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Uživatelský manuál Strana 11

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 36
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 10
UNDERSTANDING+THE+FLEX+3+COMPONENT+AND+FRAMEWORK+LIFECYCLE!
11!
!
©!2009!DevelopmentArc!LLC,!All!rights!reserved.!
child’s!parent!reference,!setting!the!child’s!document!(parent!Application)!
reference,!defines!the!LayoutManager!(this!is!very!important!for!later!phases),!
defines!which!fonts!are!available!and!starts!the!style!propagation!and!style!
management!for!the!component
7
.!
Once!addingChild() is!complete,!the!addChild() method!calls!$addChild(),!which!
is!a!Flash!Player!level!method!that!actually!adds!the!component!to!the!display!list,!
enabling!the!player!to!draw!the!components!graphical!content!to!the!screen!during!
the!render!phase!of!the!Flash!Frame
8
.!!
The!final!sub‐method!called!is!childAdded()!which!determines!if!the!child!
component!has!been!initialized!yet,!and!if!not!the!method!calls!the!initialize()!
method!on!the!child,!completing!the!Addition!phase!and!starting!the!Initialization!
phase.!
Component+Phases:+Initialization+(birth)+
The!initialization!phase!is!responsible!for!creating!children!of!the!component!and!
preparing!for!the!first!Invalidation!and!Validation!phase!cycle.!!The!initialize()!
method,!which!was!called!by!the!parent’s!childAdded(),!is!broken!down!into!four!
sub‐methods:!createChildren(),!childrenCreated(),!initializeAccessibility()!
and!initializationComplete().!!!
When!the!initialize()method!is!called,!the!UIComponent!first!dispatches!the!
FlexEvent.PREINITIALIZE event!and!then!calls!createChildren() enabling!any!
extended!component!to!create!and!then!add!child!components!to!itself
9
.!!
For!example,!the!Button!component!overrides!UIComponent’s!createChildren()!
method!to!generate!the!TextField!instance!that!renders!the!Button’s!label!text,!sets!
the!styleName of!the!TextField!to!the!Button instance!and!then!adds!the!
TextField as!a!child!of!itself!by!calling!addChild().
10
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7
!Onc e#that#the#component#has#been#added#to#the#parent,#a#lot #of#valuable#data#is#avail able#to#us #as#
developers.##An#interesting#aspect#to#note# is#that#this#is#the#first#time#that#all#the#style#inheritance#
info rmation#is#defined#and#all#the#CSS#decl arations#are#applied.##For#m ore#information#details#abou t#
style#management#in#the#component#Lifecycle,#refer#to#t he#se ction#Using!And!Accessing!Styles#
later#in#this#document.!
8
#Recall#that#a ll#the#logic#we# are#currently#executing #is#happening#during#the#execution#phase#of#th e#
Flas h#frame#
9
#By#default,#UIComponent’s #createChildren()#does#nothing# in#th e#method#body.#
10
!Its#i mportant#to#consider#the#im plications #of#createChildren()#a nd#how#it#can#start #off#a#
complex#chain#of#code#execution#(and#chil d#component#phases)#that#eventually#creat es#yo ur#entire#
applicati on’s#layout.##Looking#at#the#simple#Button#ex ample,#we#see#first#the#TextField#is#
constructed#and#then#i s#added#to#the#Button#as#a#child.##This#m eans#that#the#TextField# now#begins#
it’s#own#lifecycle.##Construction#has#alread y#occurred#and#by#adding#the#element#to#the#Button,#the#
TextField#next#enters#its#Ad dition#and#then#Initializ ation#pha se.#If#the# TextField#has#children#(in#
this#case #it#does#not)#it#would#then#construct#its#chi ldren#adding#them#to#itself#a nd#the#chain#continues#
on,#etc.#etc.!
Zobrazit stránku 10
1 2 ... 6 7 8 9 10 11 12 13 14 15 16 ... 35 36

Komentáře k této Příručce

Žádné komentáře