MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Bedienungsanleitung Seite 35

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 36
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 34
UNDERSTANDING+THE+FLEX+3+COMPONENT+AND+FRAMEWORK+LIFECYCLE!
35!
!
©!2009!DevelopmentArc!LLC,!All!rights!reserved.!
To!help!in!this!process!the!Flex!Component!architecture!has!provided!a!method!
called!styleChanged()!which!we!can!override!to!flag!our!style!changes!for!our!
Validation!Phase.!
Continuing!with!our!dataValue!component!example,!lets!say!that!our!component!
exposes!a!style!called!chartLineColor!which!is!used!by!the!drawChart()!method!to!
determine!the!line!style!color.!
[Style(name="chartLineColor",type="uint",format="Color",inherit="no")]
Figure'15')'Style'Metadata'Example'
We!want!to!make!sure!that!when!the!style!changes!that!our!chart!is!re‐drawn!and!
the!new!color!is!applied.!!We!do!this!by!overriding!the!styleChanged()!method:!
override public function styleChanged(styleProp:String):void {
super.styleChanged(styleProp);
switch(styleProp) {
case "chartLineColor":
_chartDirty = true;
invalidateDisplayList();
break;
}
}
Figure'16')'Style'Change d'Example'
When!ever!a!style!property!changes,!the!styleChanged() method!is!called
35
!passing!
in!the!name!of!the!style!that!changed.!!In!our!example!code,!we!look!for!the!
chartLineColor!style!and!if!that!has!changed,!we!mark!the!chart!as!dirty!and!then!
invalidate!the!display!list.!When!the!next!Validation!Pass!occurs,!our!chart!will!be!
marked!dirty!and!the!drawChart()!method!will!be!called
36
.!!!
This!is!just!a!basic!example!of!how!we!can!continue!leveraging!the!Invalidation‐
Validation!phases!during!our!application!development.!!There!are!many!ways!we!
can!use!this!phase!to!modify!the!look!and!feel!of!our!components.!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
#It’s #important#to#mention#that#styleChanged()#is#cal led#when#a#compon ent’s #style#property #is#
dire ctly#set#via#MX ML#during#the#birth#phase#of#the#component.##This#method#is# not#called#for#any#
properties#that#are#set#via#inheritanc e#or#Themes.##When#implementing#styles#in#your#component,#you#
should#make#sure# to#get#and#apply#all#the#styles#for# the#component#during#the#fi rst#V alida tion#pass#and#
not#rely#on#the#style#changed#method#to#flag#your#s tyles#to#determine#which#to#apply.#
36
#We #will#assume#that#the#drawChart()#m ethod#looks#up#the# associated#styl es#and#applies#them.#
Seitenansicht 34
1 2 ... 30 31 32 33 34 35 36

Kommentare zu diesen Handbüchern

Keine Kommentare