MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manuel d'utilisateur Page 30

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 36
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 29
Version#1.0#(May#14,#2009)#
override!is!dependent!on!what!you!are!trying!to!do.!!If!you!want!to!access!children!
after!they!are!created!then!you!will!probably!want!to!override!childrenCreated().!
If!you!want!to!wait!for!all!the!configuration!to!be!complete!and!to!make!sure!
initialize!is!done,!override!the!initializeComplete() method.!!This!method!is!
called!last!once!all!the!other!initialize!sub‐methods!are!done.!!By!overriding!
initialize() you!can!actually!break!this!order!and!are!potentially!making!updates!
post‐initializeComplete()!which!should!always!be!the!last!method!called.!!
If+You+Must+Override+Initialize…+
There!may!be!a!situation,!although!highly!doubtful,!where!you!just!have!to!override!
the!initialize() method.!!If!this!is!the!case,!then!here!are!a!few!important!notes.!!!
First,!you!need!to!decided!if!your!code!should!be!called!before!or!after!
super.initialize().!!When!you!call!super,!and!it!reaches!the!UIComponent!level!the!
initialize()!method!dispatches!the!PREINITIALZE!!event,!informing!the!system!
that!children!are!about!to!be!created.!!This!event!should!always!be!dispatched!
before!starting!to!create!the!children!for!the!components.!!!
Next,!the!method!calls!createChildren(),!followed!by!childrenCreated() and!
finally!initializeComplete().!If!your!code!is!called!before!super!you!need!to!be!
aware!that!the!children!up!and!down!the!inheritance!chain!do!not!exist!yet.!!If!your!
code!follows!super!then!you!are!executing!code!post‐initializeComplete()!which!
is!breaking!the!Flex!Component!defined!architecture!call!order.!
As!you!can!probably!tell,!overriding!initialize() is!a!lose‐lose!situation!in!99.9%!
of!the!cases.!!So,!once!again,!we!recommend!that!you!don’t!do!it!and!choose!another!
location!to!apply!your!configuration.!
The+Invalidation‐Validation+Cycle+and+Methods+
Understanding!the!Invalidation‐Validation!Cycle!is!probably!the!most!important!
process!for!developing!Flex!components!and!applications.!!This!cycle!is!where!most!
of!the!work!is!done!and!occurs!over!and!over!again!through!the!lifecycle!of!the!
application.!!In!this!section,!we!are!going!to!examine!some!techniques!to!leverage!
this!cycle!and!look!at!benefits!we!gain!by!applying!these!techniques.!
Separating+the+Phases+
If!you!recall,!the!Event.RENDER!event!breaks!the!Invalidation‐Validation!cycle!into!
two!distinct!phases.!!The!reason!this!is!done!is!to!enable!the!ability!to!only!call!the!
validation!code!when!it!is!required,!preventing!us!from!executing!code!
unnecessarily.!
We!are!going!to!use!an!example!for!this!section!to!demonstrate!how!to!write!code!
that!takes!advantage!of!the!Invalidation‐Validation!phase.!First,!we!will!look!at!an!
incorrect!way!of!writing!the!code!and!then!examine!how!we!can!modify!it!to!fully!
leverage!the!cycle.!!!
Vue de la page 29
1 2 ... 25 26 27 28 29 30 31 32 33 34 35 36

Commentaires sur ces manuels

Pas de commentaire