Tải bản đầy đủ (.pdf) (1,026 trang)

Adobe press adobe flex 2 training from the source oct 2006 ISBN 032142316x

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (9.62 MB, 1,026 trang )

AdobeFlex2:TrainingfromtheSource,1/e
ByJeffTapper,JamesTalbot,MattBoles,BenElmore,
MikeLabriola
...............................................
Publisher:AdobePress
PubDate:October20,2006
PrintISBN-10:0-321-42316-X
PrintISBN-13:978-0-321-42316-0
Pages:624

TableofContents|Index

PartoftheAdobeTrainingfromtheSourceseries,theofficialcurriculumfromAdobe,
developedbyexperiencedtrainers.Usingproject-basedtutorials,thisbook/CDvolumeis
designedtoteachthetechniquesneededtocreatesophisticated,professional-level
projects.EachbookincludesaCDthatcontainsallthefilesusedinthelessons,plus
completedprojectsforcomparison.Thistitlecoversthenewdevelopmentframeworkfor
RichInternetApplications,AdobeFlex2.Inthecourseofthebook,thereaderwillbuild
severalWebapplicationsusingFlexBuilderandincorporatingMXMLandActionScript3.0.


AdobeFlex2:TrainingfromtheSource,1/e
ByJeffTapper,JamesTalbot,MattBoles,BenElmore,
MikeLabriola
...............................................
Publisher:AdobePress
PubDate:October20,2006
PrintISBN-10:0-321-42316-X
PrintISBN-13:978-0-321-42316-0
Pages:624


TableofContents|Index









































Copyright
Bios
Acknowledgments
Introduction
Lesson1.UnderstandingRichInternetApplications
UnderstandingtheEvolutionofComputerApplications
BreakingawayfromthePage-basedArchitecture
IdentifyingtheAdvantagesofRichInternetApplications
RIATechnologies
Lesson2.GettingStarted
GettingStartedwithFlexApplicationDevelopment
CreatingaProjectandanMXMLApplication
UnderstandingtheFlexBuilder2Workbench
RunningYourApplication
CreatingaSecondApplicationPageandWorkinginDesignMode
GettingReadyfortheNextLesson
WhatYouHaveLearned
Lesson3.LayingOuttheInterface
LearningAboutContainers

LayingOuttheE-commerceApplicationUsingDesignMode
WorkingwithConstraint-basedLayouts
WorkingwithViewStates













































































LayingOutanApplicationinSourceMode
WhatYouHaveLearned
Lesson4.UsingSimpleControls
IntroducingSimpleControls
UsingFlexExplorertoLearnAboutSimpleControls
DisplayingImages
BuildingaDetailView
UsingDataBindingtoLinkaDataStructuretoaSimpleControl
UsingaFormLayoutContainertoLayOutSimpleControls
AddingRadioButtonsandDateFieldstotheDashboard
WhatYouHaveLearned
Lesson5.HandlingEventsandDataStructures

IntroducingHandlingEventsandComplexDataStructures
Usingthe<mx:Model>TagwithaCreationCompleteEvent
BuildingaCustomActionScriptClass
BuildingaMethodtoCreateanObject
BuildingShoppingCartClasses
ExploringtheEventObject
WhatYouHaveLearned
Lesson6.UsingRemoteXMLDatawithControls
RetrievingXMLDatawithHTTPService
PopulatingaListwithRetrievedXMLasanArrayCollectionofObjects
PopulatingaComboBoxControlandProgrammaticallyAddinganOption
UsingXMLDatawithaTreeControl
RetrievingXMLDataandTransformingitintoanArrayCollectionofCustom
Objects
UsingDataBindingwithComplexDataStructures
SortingandManipulatingShoppingCartData
AddingaRemoveButton
WhatYouHaveLearned
Lesson7.CreatingComponentswithMXML
IntroducingMXMLComponents
CreatinganUpdate/DeleteProductComponentandInstantiatingIt
PoppingUpProductInformationWhenClickingtheUpdateandDeleteButtons
CreatingAnotherValueObject
CreatingaDataManagerComponentforAllThreeApplications
UsingtheNewDataManagerComponent
ImplementingAddProductFunctionality
CreatingandUsingaComponentfortheDashboardApplication




WhatYouHaveLearned

Lesson8.UsingControlsandRepeaterswithDataSets









































































IntroducingUsingDataSets
DisplayingtheCategoriesUsingaHorizontalListandanitemRenderer
DisplayingGroceryProductsBasedonCategorySelection
CodingStatestoDisplayDetailedProductInformation
PlacingProductsintheShoppingCart
WhatYouHaveLearned
Lesson9.UsingCustomEvents
UnderstandingtheBenefitsofaLooselyCoupledArchitecture
DispatchingEvents
DeclaringEventsforaComponent
IdentifyingtheNeedforCustomEventClasses
BuildingandUsingtheCategoryEvent
CreatingandUsingtheProductEventClass
UnderstandingEventFlowandEventBubbling
WhatYouHaveLearned
Lesson10.CreatingCustomComponentswithActionScript3.0

IntroducingBuildingaComponentwithActionScript3.0
CreatingtheStructureoftheClass
OverridingthecreateChildren()Method
OverridingtheupdateDisplayList()Method
WhatYouHaveLearned
Lesson11.UsingDataGridsandItemRenderers
IntroducingDataGridsandItemRenderers
AddingaGenericDataGridtoChartPod
AddingHTTPServiceCallstoDashboard
DisplayingtheShoppingCartwithaDataGrid
WhatYouHaveLearned
Lesson12.UsingDragandDrop
IntroducingtheDragandDropManager
DraggingandDroppingBetweenTwoDataGrids
DraggingandDroppingBetweenaDataGridandaList
UsingaNondragEnabledComponentinaDrag-and-DropOperation
DraggingaGroceryItemtotheShoppingCart
WhatYouHaveLearned
Lesson13.ImplementingNavigation
IntroducingNavigation
UsingaTabNavigatorintheData-entryApplication





AddingaHomePageandCheckoutPageintheE-commerceApplication
CreatingtheFirstStepoftheCheckoutProcessDisplayedbyaViewStack



CompletingtheCheckoutProcessUsingtheViewStack

WhatYouHaveLearned

Lesson14.UsingFormattersandValidators

IntroducingFormattersandValidators

UsingaFormatterClasstoDisplayCurrencyInformationintheE-commerce

Application

UsingValidatorClasses

UsingRegularExpressionstoValidateData(Part1)

UsingRegularExpressionstoValidateData(Part2)

BuildingaCustomValidatorClass

WhatYouHaveLearned

Lesson15.UsingtheHistoryManager

IntroducingHistoryManagement

ImplementingHistoryManagementwithinaNavigatorContainer

BuildingaCustomHistoryManager


WhatYouHaveLearned

Lesson16.CustomizingtheLookandFeelofaFlexApplication

ApplyingaDesignwithStylesandSkins

ApplyingStyles

SkinningComponents

WhatYouHaveLearned

Lesson17.AccessingServer-sideObjects

IntroducingServer-sideObjects

UsingtheEventModelRemoteServerCalls

ConfiguringanApplicationtoWorkLocally

UsingaWebServiceintheDashboard

UsingaWebServiceintheDataEntryApplication

UploadingFilestotheServer

CentralizingWebServiceAccess

UsingRemoteObjecttoSaveanOrder


MappingActionScriptObjectstoServerObjects

WhatYouHaveLearned

Lesson18.ChartingData

ExploringFlexChartingComponents

LayingOuttheInitialCharts

PopulatingCharts

AddingHorizontalandVerticalAxestoLineandColumnCharts











































































AddingLegendstotheCharts
LimitingtheLabelsShownonanAxis
InteractingwithCharts
AddingChartEvents

AddingAnimationstotheCharts
CustomizingtheLookofChartswithStyles
WhatYouHaveLearned
Lesson19.IntroducingAdobeFlexDataServices
IntroducingFlexDataServices(FDS)
InstallingtheAdobeFDS
CreatingaFlexBuilderProjectwithFDS
UsingtheFlexProxyService
CreatingaNamedProxyServiceDestination
WhatYouHaveLearned
Lesson20.PushingDatawithAdobeFlexDataServices
UnderstandingFlexMessageServices
CreatingaNewProjectinFlexBuilder
UnderstandingHowtheFlexMessageServiceWorks
EnablingRemoteObjectCallstoaColdFusionServer
ConfiguringaMessageDestination
Usingthe<mx:Consumer>Tag
WhatYouHaveLearned
Lesson21.SynchronizingDatawithAdobeFlexDataServices
IntroducingtheDataManagementService
ConfiguringDataManagementServices
CreatingtheDataManagementCFCs
UsingDataManagementServiceDatainanMXMLApplication
CreatingandDeletingwiththeDataManagementService
WheretoGofromHere
WhatYouHaveLearned
Lesson22.CreatingTransitionsandBehaviors
IntroducingBehaviorsandTransitions
ImplementingEffectsonaComponent
AddingEffectstoViewStates

WhatYouHaveLearned
Lesson23.PrintingFromFlex
IntroducingFlexPrinting
PrintingfortheFirstTimefromFlex




UsingthePrintDataGridinaNonvisibleContainer




BuildingthePrintableViewinaSeparateComponent
ScalingthePrintedOutput








































PrintingaReceiptfromtheCheckoutProcess
WhatYouHaveLearned
Lesson24.UsingSharedObjects
IntroducingSharedObjects
BuildingaSharedObjecttoStoreShoppingCartData
ReadingDatafromanExistingSharedObject

WhatYouHaveLearned
Lesson25.DebuggingFlexApplications
IntroducingDebuggingTechniques
WatchingServer-ClientDataExchange
LearningMoreAbouttheDebugger
HandlingErrorswithtry-catch
WhatYouHaveLearned
AppendixA.SetupInstructions
InstallingFlexProducts
InstallingLessonFiles
InstallingtheColdFusionExtensionsforAdobeFlexBuilder2
StartingFlexDataServicesandColdFusion
InstallingFlashDebugPlayer
Index


Copyright
Adobe®Flex™2:TrainingfromtheSource
JeffTapper/JamesTalbot/MatthewBoleswithBenjamin
ElmoreandMichaelLabriola
AdobePressbooksarepublishedby
Peachpit
1249EighthStreet
Berkeley,CA94710
510/524-2178
800/283-9444
510/524-2221(fax)
FindusontheWorldWideWebat:
www.peachpit.com
www.adobe.com

Toreporterrors,pleasesendanoteto
Copyright©2007byAdobeSystems,Inc.

Authors:JeffTapper/JamesTalbot/MatthewBoleswithBenjaminElmorean
AdobePressEditor:VictorGavenda
Editor:RobynG.Thomas
TechnicalEditor:MichaelLabriola
ProductionCoordinator:BeckyWinter
CopyEditor:NancyE.Sixsmith
Compositors:RickGordon,EmeraldValleyGraphics/DebbieRoberti,Espres
Indexer:JoyDeanLee
CoverDesign:PeachpitPress


Proofreader:MarkKozlowski

NoticeofRights
Allrightsreserved.Nopartofthisbookmaybereproducedor
transmittedinanyformbyanymeans,electronic,mechanical,
photocopying,recording,orotherwise,withoutthepriorwritten
permissionofthepublisher.Forinformationongetting
permissionforreprintsandexcerpts,contact


Trademarks
Flash,ColdFusion,andAdobeareregisteredtrademarksof
AdobeSystems,Inc.FlexisatrademarkofAdobeSystems,
Inc.
Throughoutthisbook,trademarkednamesareused.Rather
thanputatrademarksymbolineveryoccurrenceofa

trademarkedname,westatethatweareusingthenamesinan
editorialfashiononlyandtothebenefitofthetrademarkowner
withnointentionofinfringementofthetrademark.

NoticeofLiability
Theinformationinthisbookisdistributedonan"AsIs"basis,
withoutwarranty.Whileeveryprecautionhasbeentakeninthe
preparationofthebook,neithertheauthor,AdobeSystems,
Inc.northepublisher,shallhaveanyliabilitytoanypersonor
entitywithrespecttoanylossordamagecausedorallegedto
becauseddirectlyorindirectlybytheinstructionscontainedin
thisbookorbythecomputersoftwareandhardwareproducts
describedinit.
PrintedandboundintheUnitedStatesofAmerica


987654321

Dedication
MyeffortsonthisbookarededicatedtomywifeLisaand
daughterKaliope.EverythingIdo,Idoforyoutwo.
JeffTapper
Myeffortsarededicatedtomyfamilyandfriendsaswell
astheAdobeTrainingandConsultingteamsforgivingme
theincredibleopportunitiesthathaveallowedthisbookto
cometobe.
JamesTalbot
Tofriends.
ToSandra,mybestfriendandwife,whohashelpedand
supportedmeinsomanywaysovertheyears.Thanksfor

supportingmeevenwhenIchosetodocrazythings,
includingwritingthisbook.
Tomysiblings,Melissa,Todd,Jody,andKent(andtheir
wonderfulfamilies)whocontinuetobebetterandbetter
friendswitheachpassingyear.
ToBryanandColleen,whoprovethatoncebuilt,asolid
friendshipcan'tbediminishedwithtimeordistance.
ToBobandConnie,whowerewillingtobefriendswhenI
neededitmost,evenattheexpenseoftheirtime.
ToSue,Robert,James,Deborah,Tina,Cathrine,Leo,Jon,
andJim,whoarenotonlymycolleaguesinAdobe
CustomerTraining,butwhohavealsobecomegreat
friends.


MatthewBoles
ThisbookisdedicatedtomykidsOlivia,Haydn,Sydney,
Carrington,andGriffen.Itisalwayshardtotaketime
awayfromyouforsuchataskaswriting.
BenjaminElmore
TomywifeLaura;youalwaysmakemesmile.
MichaelLabriola




Bios
JeffTapperistheChiefTechnologistandCEOforTapper,
NimerandAssociates,Inc.HehasbeendevelopingInternetbasedapplicationssince1995foramyriadofclientsincluding
MorganStanley,Doctations,ToysRUs,IBM,DowJones,

AmericanExpress,M&TBank,Verizon,andmanyothers.He
hasbeendevelopingFlexapplicationssincetheearliestdaysof
Flex1.AsanInstructor,JeffiscertifiedtoteachallofAdobe's
coursesonFlex,ColdFusion,andFlashdevelopment.Heisalso
afrequentspeakeratAdobeDevelopmentConferencesand
usergroups.JeffTapperandMikeNimerformedTapper,Nimer
andAssociatesprovideexpertguidancetorichInternet
applicationdevelopmentandempowerclientsthrough
mentoring.
JamesTalbothasbeenwithAdobe(formerlyMacromedia)for
morethansixyears,onboththesalesengineeringandtraining
teams,andhasmostrecentlybeenworkingwithFlexandFlash
Lite.Hehastraveledextensivelythroughouttheworld
promotingAdobeproductsandcertifyingAdobeinstructorsas
wellasspeakingatconferences.Jameshasbeenanintegral
teammemberonhighprofilerichInternetapplication
consultingassignmentsforcompaniessuchasAOL/Time
Warner,JPMorgan,Fidelity,andTVGuide.
JamesisactivelyinvolvedintheAdobeworldwideinstructorand
developercommunity,andcontributestodevelopercertification
examsaswellasorganizingandspeakingatusergroups.
JamesispassionateaboutFlashondevicesaswellasrich
Internetapplicationsandhebelievesthatbothtechnologieswill
changetheworldforthebetter.
MatthewBolesistheTechnicalLeadfortheAdobeCustomer
Traininggroupandhasbeendevelopingandteachingcourses
onFlexsincethe1.0release.Matthewhasadiverse


backgroundinwebdevelopment,computernetworking,and

teachinginbothprofessionalcomputerclassesandthepublic
schools.Inadditiontothisbook,Matthewco-authoreda
versionoftheCertifiedColdFusionDeveloperStudyGuide.He
hasalsodevelopedofficialAllaire/Macromedia/Adobecurricula
inbothColdFusionandFlashdevelopmentcontentareas.
BenjaminElmoreisthefounderandprincipalpartnerofTwin
Technologies,anenterpriseconsultingcompanythatspecializes
indeliveringrichInternetapplicationsforFortune500
companies.BenhasbeenworkingintheRIA/Web2.0spaces
sinceitsinceptionandhasauthoredseveralbooksonavariety
oftechnologies.BenfoundedTwinTechnologieswithacore
principleofembracingasharedknowledgebasewithinthe
developmentcommunity.WhenleadingTwinTechnologies,Ben
travelstoAfricaandTurkeytospeakonleadershiponbehalfof
theEQUIPorganization(www.iequip.org),whosegoalistoraise
amillionChristianleadersoverfiveyears.Adevotedfamily
man,BenliveswithhiswifeMaryandtheirfivechildrenin
upstateNewYork.
MichaelLabriola,whohasdevotedadecadeandahalfto
Internettechnologies,isaSeniorConsultantandProjectLead
forDigitalPrimates,Inc.Hespendshismorningsteaching
developerstoworkwithFlex;hisafternoonscreatingrich
InternetapplicationsthatgeneratesignificantROIforclients;
andhisnightsdreamingupwaystouseFlexthatitsdesigners
neverintended.




Acknowledgments

IwouldliketothankMatt,James,Ben,andMikeforall
theirhardwork,whichhashelpedshapethisbook.
SpecialthanksgototheteamatAdobe/Macromedia,
whichhasmadethisallpossible,especiallytheeffortsof
DavidMendels,PhilCosta,andMikeNimerallofwhom
haveofferedinvaluableadviceduringthisprocess.Thanks
toTadStaleyofAdobeconsulting,whohasgivenmemore
opportunitiesthananyoneelsetoworkonFlexprojects.I
wouldalsoliketoacknowledgeDoctationsandtheIT
ReferenceDatadepartmentatMorganStanley,clients
whoseFlex2projectscoincidedwiththewritingofthis
book.Thisbookcouldn'tpossiblyhavebeenwritten
withoutthelessonsIlearnedontheirprojects,norcould
theirprojectshavebeensuccessfullycompletedwithout
myworkonthisbook.Thankstotheeditorialstaffat
AdobePress,whowasfacedwiththeHerculeantaskof
makingourwritingsintelligible.Finally,thankstothe2004
WorldSeriesChampionBostonRedSox.
JeffTapper
Thisbookhasconsumedmany,manyhoursandsleepless
nights,butitisallduetotheincredibleeffortsofJeff,
Matt,Ben,andMichael.Iwouldliketothankeachoneof
themandofferaspecialthankstoMichaelandRobyn.
Thisbookcouldnothavebeenasuccesswithoutthe
incrediblesteadfastnessofbothMichaelandRobyn,who
demonstratedincredibleeagleeyesandneverwaveredin
theirresolvetopublishtheverybest.Thankstoeveryone
atAdobe,includingDavidMendels,ShoKuwamoto,Eric
Anderson,PhilCosta,andeveryoneelseontheFlexand
FlexBuilderteams.I'dliketoofferaspecialthanksto

Robert,Sue,Leo,Cathrine,andJazmineontheAdobe


trainingteam,whoseeffortsallowedmetohavetimeto
workonthisbook.
JamesTalbot
Gettingthisbookfinishedhasbeenalongandarduous
road,andIcouldnothavecompletedthejourneywithout
Jeff,James,Mike,Ben,andRobyn.IhopeMikecan
forgivemeforgettinghiminvolvedinaprojectthathas
takenmuchmoretimethaneitherofuscouldhaveever
imagined.IalsohopeRobyncanforgivealloftheauthors
formakingthissuchalongproject.Joshandtherestof
thegangatDigitalPrimatesdeservekudosforthework
theyhavedoneintestingthisbook.ThanksalsotoDave
Mendels,PhilCosta,ShoKuwamoto,HeidiWilliams,and
therestoftheFlexandFlexBuilderteamsforbuilding
greatproductsandhelpingmeunderstandthem.Also
thankstoBobTierneyandKevinHoytforgivingdosesof
realityFlexwhenneeded.
MatthewBoles
Iheardsomeoneoncesaythatthebestpartofwritingis
whenitisoverandyougettoseethebenefitofyour
labor.MypartinthisbookwasasimpleoneandIwould
liketoacknowledgethegreatworkdonebymycoauthorswhoshoulderedthelargestshare.Thankyoufor
theopportunitytoassistwiththebook;itwasapleasure.
Atarecenttechnologyget-togetherIranintomyfirst
mentor,GregFisher.Myexperienceinlifehasshownme
thatyoucaneitherhoardorshareyourknowledgewith
thosearoundyou.Iamgratefulforyourwillingnessso

manyyearsagotochoosetoinvestandsharewithme.
FinallyIwouldliketoacknowledgethesacrificeand
supportofmywifeMary,theobjectofmyeternal


affection.
BenjaminElmore
IwouldliketothankMatt,Jeff,James,andBenfortheir
workanddedicationtobringingthisprojecttogether.
ThankstoRobynforherdiligence,understandingand
patienceduringtheprocess.ThankstoJosh,Jim,and
PeteroftheDigitalPrimates'teamforhoursofreading,
runningcode,supportingmyhalf-thought-outideas,and
generallybeinggreatfriendsandcolleagues.Thanksto
Shirlforhercandorandcounsel,andspecificallyfor
pushingmeinthisdirection.ThankstoMattforinviting
metojointhisprojectandteam.Thankstomyfamilyfor
theencouragementtheyalwaysprovide.Finally,thanksto
mywifeLaura,whosupportsmycraziestideaswitha
smileandalotofunderstanding.
MichaelLabriola




Introduction
It'sjustafewshortyearssinceMacromediacoinedtheterm
richInternetapplication.Backthen,theideafeltsomewhat
futuristic,butallthathaschanged.richInternetapplications(or
RIAs,asweaffectionatelyrefertothem)arerealityandthey

arehererightnow.
MacromediareleasedFlexacoupleofyearsago,makingit
possiblefordeveloperstowriteapplicationsthattake
advantageoftheincrediblyprevalentFlashplatform.These
applicationsdon'tjustlookgreat;theyalsoaretrulyportable,
canbefullyaccessible,and(mostimportantly)dramatically
changetheenduserexperiencereplacingthepagerequest
modelofthewebtosomethingfarmoreelegantandusable.
Somethingricher.
NumerousorganizationshavediscoveredthebenefitsofFlex
andhavesuccessfullybuiltanddeployedapplicationsthatrun
ontopoftheFlashplatform.Thehighestprofileoftheseis
Yahoo!,whichcreatedthenextgenerationofYahoo!Mapsin
Flex.ButdespitetheearlyFlexsuccesses,Flex1wasmost
definitelynotamassmarketproduct.Pricing,tooling,
deploymentoptions,andmoremeantthatFlex1wastargeted
specificallyforlargerandmore-complexapplications,aswellas
formore-sophisticateddevelopersanddevelopment.Butthis
hasnowchanged.
NowpartoftheAdobefamily,Flex2wasreleasedmid2006a
brandnewFlexwithanewintegrateddevelopment
environment(IDE),newpricing,newdeploymentoptions,a
newscriptinglanguage,andabrandnewFlashPlayertoo.Flex
2ismostdefinitelyamassmarketproduct,designedtobring
thevaluesandbenefitsofRIAstoalldevelopers.
GettingstartedwithFlexisprettyeasy.MXMLtagsareeasyto


learn(especiallywhenFlexBuilderwritesmanyofthemfor
you).ActionScripthasasteeperlearningcurve,butdevelopers

withpriorprogrammingandscriptingexperiencewillpickitup
easily.ButthereismoretoFlexdevelopmentthanMXMLand
ActionScript.
Therearemanythingsthatneedtobeunderstoodtobea
successfulFlexdeveloper,includingthefollowing:
HowFlexapplicationsshouldbebuilt(andhowtheyshould
not)
RelationshipsbetweenMXMLandActionScript,andwhento
useeach
Variouswaystointeractwithback-enddata,andthe
differencesbetweeneach
HowtousetheFlexcomponents,andknowhowtowrite
theirown
Performanceimplicationsofthecodetheywriteandhowit
iswritten
Bestpracticestowritecodethatisscalableandmanageable
andreusable(thereisdefinitelymoretoFlexthanMXML
andActionScript)
Andthisiswherethisbookcomesin.MatthewBoles,James
Talbot,andJeffTapper(ablyassistedbyBenjaminElmoreand
MichaelLabriola)havedistilledtheirhard-earnedFlexexpertise
intoaseriesoflessonsthatwilljump-startyourownFlex
development.Startingwiththebasicsandthenincrementally
introducingadditionalfunctionalityandknow-how,theauthor
teamwillguideyourjourneyintotheexcitingworldofRIAs,


ensuringsuccessateverystepoftheway.
Flex2ispowerful,highlycapable,fun,andincrediblyaddictive,
too.AndAdobeFlex2:TrainingfromtheSourceistheideal

tourguideonyourjourneytothenextgenerationofapplication
development.
Enjoytheride!
BenForta
SeniorTechnicalEvangelist
AdobeSystems,Inc.

Prerequisites
Tomakethemostofthiscourse,youshouldattheveryleast
understandwebterminology.Thisbookisn'tdesignedtoteach
youanythingmorethanFlex,sothebetteryourunderstanding
oftheWorldWideWeb,thebetteroffyou'llbe.Thisbookis
writtenassumingthatyouarecomfortableworkingwith
programminglanguagesandareprobablyworkingwitha
server-sidelanguagesuchasJava,.Net,PHP,ColdFusion,ora
similartechnology.Althoughknowledgeofserver-side
technologiesisnotrequiredtosucceedwiththisbook,thereare
manycomparisonsandanalogiesmadetoserver-sideweb
programming.Thisbookisnotintendedasanintroductionto
programmingorasanintroductiontoobject-oriented
programming(OOP).ExperiencewithOOPisnotrequired,
althoughifyouhavenoprogrammingexperienceatall,you
mightfindthematerialstooadvanced.

Outline
Asyou'llsoondiscover,thisbookmirrorsreal-worldpracticesas
muchaspossible.Wherecertainsectionsofthebookdepart
fromwhatwouldbeconsideredareal-worldpractice,every



attempthasbeenmadetoinformyou.Theexercisesare
designedtogetyouusingthetoolsandtheinterfacequicklyso
thatyoucanbegintoworkonprojectsofyourownwithas
smoothatransitionaspossible.
Thiscurriculumshouldtakeapproximately3840hoursto
completeandincludesthefollowinglessons:
Lesson1:UnderstandingRichInternetApplications
Lesson2:GettingStarted
Lesson3:LayingOuttheInterface
Lesson4:UsingSimpleControls
Lesson5:HandlingEventsandDataStructures
Lesson6:UsingRemoteXMLDatawithControls
Lesson7:CreatingComponentswithMXML
Lesson8:UsingControlsandRepeaterswithDataSets
Lesson9:UsingCustomEvents
Lesson10:CreatingCustomComponentswithActionScript3.0
Lesson11:UsingDataGridsandItemRenderers
Lesson12:UsingDragandDrop
Lesson13:ImplementingNavigation
Lesson14:UsingFormattersandValidators
Lesson15:UsingtheHistoryManager
Lesson16:CustomizingtheLookandFeelofaFlexApplication


Lesson17:AccessingServer-sideObjects
Lesson18:ChartingData
Lesson19:IntroducingAdobeFlexDataServices
Lesson20:PushingDatawithAdobeFlexDataServices
Lesson21:SynchronizingDatawithAdobeFlexDataServices
Lesson22:CreatingTransitionsandBehaviors

Lesson23:PrintingFromFlex
Lesson24:UsingSharedObjects
Lesson25:DebuggingFlexApplications
AppendixA:SetupInstructions

TechnicalNotes
Beforegettingstarted,youshouldfollowthesetupinstructions
intheappendixtoensurethatyouhavetheenvironmentsetup
properlyforusewiththisbook.
Muchofthedataforthehands-ontasksisretrievedfrom
www.flexgrocer.com.Ofcourse,youmusthaveanInternet
connectiontoaccessthissite.Inlieuofthis,youcanstartthe
ColdFusionserverinstance,asdetailedintheappendix,"Setup
Instructions,"andchangetheURLfrom
tohttp://localhost:8300/and
accessthedatalocally.Forexample,inLesson6,"Using
RemoteXMLDatawithControls,"simplyreplace
with
http://localhost:8300/units.xmltoaccessthesameXMLdata
withoutanInternetconnection.


Throughoutthebook,weusethiswording:"Datatypethe
functionasvoid"or"DatatypethefunctionasString."Thisis
justtomaketheinstructionssimpler;theauthorsrealizethe
functionitselfisnotdatatypedwhatisreallybeingdatatypedis
thevaluethefunctionreturns.

WhoIsthisBookFor?
MacintoshandWindowsusersofFlexBuilder2cancompleteall

theexercisesinLessons1-16.Lessons17-25,however,cover
FlexDataServices,whichonlyrunsunderWindows.Macintosh
userscancontinuewiththoseChaptersiftheyhaveaccesstoa
FlexDataserverrunningonaseparatemachine.Settingup
thatserverandconnectingtoitis,alas,beyondthescopeof
thisbook.

TheProjectApplication
AdobeFlex2:TrainingfromtheSourceincludesmany
comprehensivetutorialsdesignedtoshowyouhowtocreatea
completeapplicationusingFlex2.Thisapplicationisan"online
grocerystore"thatdisplaysdataandimagesandthensubmits
completedorderstotheserver.Itincludesanexecutive
Dashboardtoenablestoremanagerstoviewreal-timegraphs
showingsalesdetails,aswellasadata-entryapplicationfor
addingoreditingtheproductssoldbythegrocery.
Bytheendof25hands-onlessons,youwillhavebuiltanentire
websiteusingFlex.Youwillbeginbylearningthefundamentals
ofFlexandunderstandinghowFlexBuildercanbeusedtoaid
indevelopingapplications.Intheearlylessons,youwillmake
useofDesignmodetobeginlayingouttheapplication,butas
youprogressthroughthebookandbecomemorecomfortable
withthelanguagesusedbyFlex,youwillspendmoreandmore
timeworkinginSourcemode,whichgivesyouthefullfreedom
andflexibilityofcoding.Bytheendofthebook,youshouldbe


fullycomfortableworkingwiththeFlexlanguagesandcan
probablyworkevenwithoutFlexBuilderbyusingthefreely
availableFlex2SDKandcommand-linecompiler.


StandardElementsintheBook
Eachlessoninthisbookbeginsbyoutliningthemajorfocusof
thelessonathandandintroducingnewfeatures.Learning
objectivesandtheapproximatetimeneededtocompleteallthe
exercisesarealsolistedatthebeginningofeachlesson.The
projectsaredividedintoexercisesthatexplaintheimportance
ofeachskillyoulearn.Everylessonwillbuildontheconcepts
andtechniquesusedinthepreviouslessons.
Tips( ):Alternativewaystoperformtasksandsuggestions
toconsiderwhenapplyingtheskillsyouarelearning.
Notes( ):Additionalbackgroundinformationtoexpandyour
knowledgeandadvancedtechniquesyoucanexploretofurther
developyourskills.
Cautions( ):Informationwarningyouofsituationsyou
mightencounterthatcouldcauseerrors,problems,or
unexpectedresults.
Boldfacetext:Wordsthatappearinboldfacearetermsthat
youmusttypewhileworkingthroughthestepsinthelessons.
Boldfacecode:Linesofcodethatappearinboldfacewithin
codeblockshelpyoueasilyidentifychangesintheblockthat
youaretomakeinaspecificstepinatask.
labelFunction="multiDisplay"
columnWidth="130"
width="850"/>


Codeintext:Codeorkeywordsappearslightlydifferentfromthe
restofthetextsoyoucanidentifythem.

TohelpyoueasilyidentifyActionScript,XML,andHTMLcode
withinthebook,thecodehasbeenstyledinaspecialfont
that'suniquefromtherestofthetext.Singlelinesofcodethat
arelongerthanthemarginsofthepageallowwraptothenext
line.Theyaredesignatedbyanarrowatthebeginningofthe
continuationofabrokenlineandareindentedundertheline
fromwhichtheycontinue.Forexample:

[Viewfullwidth]

publicfunctionProduct(_catID:Number,_prodName:String,_uni
_listPrice:Number,_description:String,_isOrganic:Boolean,_
:String)

Italicizedtext:Wordsthatappearinitalicsareeitherfor
emphasisorarenewvocabulary.
Italicsarealsousedonplaceholders,inwhichtheexactentry
maychangedependinguponyoursituation.Forexample:
driveroot:/flex2tfs/flexGrocer,wherethedriverootisdependent
uponyouroperatingsystem.
Menucommandsandkeyboardshortcuts:Thereareoften
multiplewaystoperformthesametaskinFlash.Thedifferent
optionswillbepointedoutineachlesson.Menucommandsare
shownwithanglebracketsbetweenthemenunamesand
commands:Menu>Command>Subcommand.Keyboard
shortcutsareshownwithaplussignbetweenthenamesof
keystoindicatethatyoushouldpressthekeyssimultaneously;
forexample,Shift+TabmeansthatyoushouldpresstheShift
andTabkeysatthesametime.



Appendix:Thisbookincludesoneappendixthatwillguideyou
throughthestepstosetuptheworkingenvironmentrequired
toexecutetheexercisesinthisbook.
CD-ROM:TheCD-ROMincludedwiththisbookincludesallthe
mediafiles,startingfiles,andcompletedprojectsforeachof
thelessonsinthebook.Thesefilesarelocatedintheassets,
start,orcompletedirectories,respectively.Lesson1,
"UnderstandingRichInternetApplications,"doesnotinclude
tasks;however,theCD-ROMincludesmediainthedirectory
Lesson1.ThismediaprovidestheflexGrocerdirectoryforyour
project.Atanypointyouneedtoreturntotheoriginalsource
material,youcanrestoretheflexGrocer.Somelessonsinclude
anintermediatedirectory,whichcontainsfilesinvariousstages
ofdevelopmentinthelesson.Anytimeyouwanttoreference
oneofthefilesbeingbuiltinalessontoverifythatyouare
correctlyexecutingthestepsintheexercises,youwillfindthe
filesorganizedontheCD-ROMunderthecorrespondinglesson.
Forexample,thefilesforLesson4arelocatedontheCD-ROM
intheLesson4folder.
Thedirectorystructureofthelessonsyouwillbeworkingwith
isasfollows:

[Viewfullsizeimage]


×