MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Bedienungsanleitung Seite 27

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 36
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 26
UNDERSTANDING+THE+FLEX+3+COMPONENT+AND+FRAMEWORK+LIFECYCLE!
27!
!
©!2009!DevelopmentArc!LLC,!All!rights!reserved.!
SystemManager!duties.!!The!Application!enters!its!Update!phase!and!the!system!
continues!like!this!until!the!user!closes!or!quits!the!application.!
Flex+Application+Ph a s e:+Destruction+
The!Destruction!phase!of!a!Flex!Application!is!truly!dependent!on!the!how!the!
application!is!being!executed.!!In!the!browser,!the!destruction!phase!is!quick!and!
unannounced!to!the!application!meaning!that!you!have!no!control!of!what!the!app!
does!during!this!time.!!!This!also!means!that!the!exact!order!of!operation!is!really!
hard!to!tease!out.!!We!will!cut!to!the!chase!and!just!say!that!when!the!user!closes!the!
browser,!it!kills!the!SWF!instance!and!there!is!not!much!you!can!do!about!it,!at!least!
not!purely!in!ActionScript
31
.!
In!AIR!applications,!you!have!much!more!fine!control!with!the!
WindowedApplication!Class.!!AIR!provided!multiple!handlers!to!the!closing!events!
dispatched!by!the!application!so!that!you!can!elegantly!handle!exiting!of!the!
application!or!even!prevent!the!application!from!being!closed.!!Once!again,!the!exact!
order!of!operation!is!unknown!because!NativeWindow!and!NativeApplication!are!
both!included!in!the!playerglobal.swc!and!therefore!we!do!not!have!access!to!the!
code!to!allow!us!an!in‐depth!analysis.!
Flex+Component+Deve lopment+Best+Practices+
Now!that!we!have!fully!explored!the!Flex!Component!and!Application!Lifecycles,!we!
can!use!this!knowledge!to!begin!defining!some!development!best!practices.!!We!will!
examine!different!features!and!how!we!can!leverage!(or!avoid)!them!to!make!our!
applications!and!components!work!to!their!best!ability.!
Using+Constructio n+
One!of!the!misconceptions!of!the!Flex!development!process!is!that!using!the!
constructor!to!configure!your!application!is!a!good!approach.!!Fundamentally,!the!
idea!of!setting!up!your!properties!in!the!constructor!makes!sense,!yet!after!studying!
the!Lifecycle,!the!potential!pitfalls!of!relying!on!the!constructor!becomes!more!
apparent.!
One!example!of!a!potentially!hazardous!decision!is!setting!style!properties!during!
the!construction!of!your!component.!!Technically!this!would!work,!the!setStyle()!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31
#There#are#some#interesting#tricks#you#can#do#with#JavaScrip t#and#the#Browser#to#try#and#give#your#
applicati on#a# heads#up.##One #approach,#proposed#by#Andrei#Lo nescu,#is#to#have#JavaScript#listen#for#t he#
onbeforeunlo ad()#event#of#the#browser#window.##At#that#poin t,#you#have#the#JavaScript#d isplay#a#dialog#
to#a llow#the#user#t o#chose#if#they #want#to#quit#or#no t#and#at#the#same#t ime#tell#the#app#via#External#
Interface#tha t#the#browser#may#be#closing.##We#have#not#tested#this#process,#so#we#ca nnot #state#this#is#a#
best#practice# for#h andling#this#kind#o f#situation.#Bu t#it#is#really#cool#idea!#
#
http://www.flexer .info/2008/02/25/browser^window^close^event^an d^flex^applicat ions/#
#
#
Seitenansicht 26
1 2 ... 22 23 24 25 26 27 28 29 30 31 32 ... 35 36

Kommentare zu diesen Handbüchern

Keine Kommentare