Flex For Flash Developers FF 2006 final

Views:
 
     
 

Presentation Description

No description available.

Comments

By: sarathcv707 (76 month(s) ago)

its very nice

Presentation Transcript

Flex for Flash Developers: 

Flex for Flash Developers Sho Kuwamoto Sr. Director, Engineering Adobe Systems, Inc.

What is Flex?: 

What is Flex? Tag/script-based app development for Flash ActionScript class library Layout Effects, skins, etc. Networking and data Compiler, debugger, and other tools

HTML vs Flex vs Flash: 

HTML vs Flex vs Flash Unlike HTML, Flex was designed for application development (no more creating navbars by slicing up images!) HTML / CSS files Includes JavaScript libraries Tag-based HTML output HTML Flex Flash MXML / CSS files Components ActionScript classes Tag-based SWF output FLA files Symbols ActionScript classes Timeline-based SWF output format reuse behavior metaphor output

Let’s see some code: 

Let’s see some code

Our first application – Step1.mxml: 

Our first application – Step1.mxml andlt;Applicationandgt; andlt;Panelandgt; andlt;Label text='Hello, world!' /andgt; andlt;Button label='goodbye' /andgt; andlt;/Panelandgt; andlt;/Applicationandgt;

Adding layout – Step2.mxml: 

Adding layout – Step2.mxml andlt;Applicationandgt; andlt;Panel layout='absolute' width='80%' height='80%'andgt; andlt;TextArea text='Hello, world!' top='10' bottom='71' left='10' right='30'/andgt; andlt;Button label='goodbye' right='30' bottom='41'/andgt; andlt;/Panelandgt; andlt;/Applicationandgt;

Adding styles – Step3.mxml: 

Adding styles – Step3.mxml andlt;Applicationandgt; andlt;Styleandgt; TextArea { font-size: 36px; font-weight: bold; } andlt;/Styleandgt; andlt;Panel layout='absolute' width='80%' height='80%'andgt; andlt;TextArea text='Hello, world!' top='10' bottom='71' left='10' right='30'/andgt; andlt;Button label='goodbye' right='30' bottom='41'/andgt; andlt;/Panelandgt; andlt;/Applicationandgt;

Adding behavior – Step4a.mxml: 

Adding behavior – Step4a.mxml andlt;Applicationandgt; andlt;Style source='style.css'/andgt; andlt;Panel id='myPanel' layout='absolute' width='80%' height='80%'andgt; andlt;TextArea text='Hello, world!' top='10' bottom='71' left='10' right='30'/andgt; andlt;Button label='goodbye' right='30' bottom='41' click='myPanel.visible = false'/andgt; andlt;/Panelandgt; andlt;/Applicationandgt;

Adding behavior – Step4b.mxml: 

Adding behavior – Step4b.mxml andlt;Applicationandgt; andlt;Style source='style.css'/andgt; andlt;Scriptandgt; public function goodbye() : void { myPanel.visible = false; } andlt;/Scriptandgt; andlt;Panel id='myPanel' layout='absolute' width='80%' height='80%'andgt; andlt;TextArea text='Hello, world!' top='10' bottom='71' left='10' right='30'/andgt; andlt;Button label='goodbye' right='30' bottom='41' click='goodbye()'/andgt; andlt;/Panelandgt; andlt;/Applicationandgt;

Adding behavior – Step4c.mxml: 

Adding behavior – Step4c.mxml andlt;Application initialize='doInit()'andgt; andlt;Style source='style.css'/andgt; andlt;Script source='Step4c_code.as'/andgt; andlt;Panel id='myPanel' layout='absolute' width='80%' height='80%'andgt; andlt;TextArea text='Hello, world!' top='10' bottom='71' left='10' right='30'/andgt; andlt;Button id='goodbyeButton' label='goodbye' right='30' bottom='41'/andgt; andlt;/Panelandgt; andlt;/Applicationandgt;

Adding behavior – Step4c_code.as: 

Adding behavior – Step4c_code.as public function doInit() : void { goodbyeButton.addEventListener('click', goodbye); } public function goodbye(event: Event) : void { myPanel.visible = false; }

Adding states – Step5.mxml: 

Adding states – Step5.mxml andlt;Application initialize='doInit()'andgt; andlt;statesandgt; andlt;State name='small'andgt; andlt;SetProperty target='{myPanel}' property='height' value='200'/andgt; andlt;SetProperty target='{myPanel}' property='width' value='300'/andgt; andlt;/Stateandgt; andlt;/statesandgt; andlt;Style source='style.css'/andgt; andlt;Script source='Step5_code.as'/andgt; andlt;Panel id='myPanel' layout='absolute' width='80%' height='80%'andgt; andlt;TextArea text='Hello, world!' top='10' bottom='71' left='10' right='30'/andgt; andlt;Button id='goodbyeButton' label='goodbye' right='30' bottom='41'/andgt; andlt;Button id='smallButton' label='small' left='10' bottom='41'/andgt; andlt;/Panelandgt; andlt;/Applicationandgt;

Adding states – Step5_code.as: 

Adding states – Step5_code.as public function doInit() : void { goodbyeButton.addEventListener('click', goodbye); smallButton.addEventListener('click', makeSmall); } public function goodbye(event: Event) : void { myPanel.visible = false; } public function makeSmall(event: Event) : void { currentState = 'small'; }

Adding effects – Step6.mxml: 

Adding effects – Step6.mxml andlt;Applicationandgt; andlt;statesandgt; andlt;State name='small'andgt; andlt;SetProperty target='{myPanel}' property='height' value='200'/andgt; andlt;SetProperty target='{myPanel}' property='width' value='300'/andgt; andlt;/Stateandgt; andlt;/statesandgt; andlt;Style source='style.css' /andgt; andlt;Script source='Step6_code.as' /andgt; andlt;Panel id='myPanel' layout='absolute' width='80%' height='80%' hideEffect='Fade' resizeEffect='Resize'andgt; andlt;TextArea text='Hello, world!' top='10' bottom='71' left='10' right='30'/andgt; andlt;Button id='goodbyeButton' label='goodbye' right='30' bottom='41'/andgt; andlt;Button id='smallButton' label='small' left='10' bottom='41'/andgt; andlt;/Panelandgt; andlt;/Applicationandgt;

Deeper dives: 

Deeper dives

Application structure: 

Application structure Flex Application Framework Code behind (AS) CSS Component MXML Component App-specific component (AS/MXML) Reusable component library State State State SWF Skins andamp; Styles Layout andamp; Effects Behavior andamp; Data Components Designer Developer

Designers and developers: 

Designers and developers Responsible for skinning and styling through CSS and SWF Does initial layout. May do final layout (via tool) Does effect and transition design. Responsible for program logic and component development May be responsible for final layout (via containers) May implement effects and transitions Connects to data and services Designer Developer MXML AS CSS/SWF

Keys to des/dev workflow: 

Keys to des/dev workflow Separate out code into 'code behind' pages Use andlt;Script source='xxx'andgt; or other methods to separate the ActionScript code Add event handlers from ActionScript, not MXML Try not to write fancy data binding code in MXML Do not create visual components programmatically unless absolutely necessary Do as much styling in CSS as possible Use states when possible to express changes to user interface

Skinning and styling: 

Skinning and styling SWF files or GIF/PNG can be used for skinning SWF attached to controls via CSS Scale 9 can be done in SWF or in CSS CSS gives tons of control for the look of Flex controls http://weblogs.macromedia.com/mc/archives/FlexStyleExplorer.html CSS styles can be defined per tag, or per class

Working with states – music app: 

Working with states – music app welcome top 100 by genre user user - edit login genre listing which genre? which user?

How are the states related?: 

How are the states related? welcome top 100 by genre user - edit genre listing (base state) (listing) user

When do effects run?: 

When do effects run? When a specific trigger fires e.g., show, hide, and resize When a transition from one state to another occurs andlt;Transition fromState='xxx' toState='yyy'andgt; andlt;Effect /andgt; andlt;/Transitionandgt; When called explicitly through ActionScript myEffect.play();

Defining your own effects: 

Defining your own effects Using parallel and sequence andlt;Parallelandgt; andlt;Dissolve duration='500' alphaFrom='1' alphaTo='0' /andgt; andlt;Dissolve duration='500' startDelay='500' alphaFrom='0' alphaTo='0' /andgt; andlt;Resize duration='500' startDelay='500' widtoTo='50' heightTo='50' /andgt; andlt;/Parallelandgt; Effects can also be defined programmatically

Interstate gotchas: 

Interstate gotchas Control how the state change interacts with effects by using SetPropertyAction, et. al. andlt;Transition fromState='from' toState='to'andgt; andlt;Sequence target='{startPanel}'andgt; andlt;Dissolve duration='500' alphaFrom='1' alphaTo='0' /andgt; andlt;SetPropertyAction property= 'visible' value= 'false' /andgt; andlt;/ Sequence andgt; andlt;/Transitionandgt;

Components: 

Components MyApp.mxml Break your application into pieces using components andlt;Applicationandgt; andlt;Scriptandgt; function initStartPanel() {…} function initDetailPanel() {…} andlt;/Scriptandgt; andlt;HBoxandgt; andlt;Panel id='startPanel' creationComplete='initStartPanel()'andgt; … andlt;/Panelandgt; andlt;Panel id='detailPanel' creationComplete='initDetailPanel()'andgt; … andlt;/Panelandgt; andlt;/HBoxandgt; andlt;/Applicationandgt;

Components: 

Components MyApp.mxml StartPanel.mxml Break your application into pieces using components andlt;Applicationandgt; andlt;HBoxandgt; andlt;StartPanel id='startPanel'/andgt; andlt;DetailPanel id='detailPanel'/andgt; andlt;/HBoxandgt; andlt;/Applicationandgt; andlt;Panel creationComplete='initStartPanel()'andgt; andlt;Scriptandgt; function initStartPanel() {…} andlt;/Scriptandgt; … andlt;/Panelandgt;

Service calls: 

Service calls Make calls to the server using RPC calls andlt;HTTPService url='xxx' request='yyy' /andgt; andlt;WebService wsdl='xxx'andgt; andlt;operation name='yyy' /andgt; andlt;/WebServiceandgt; andlt;RemoteObject destination='xxx'andgt; andlt;method name='yyy' /andgt; andlt;/RemoteObjectandgt;

Service calls: 

Service calls Results come asynchronously; listen for the 'result' event. Alternatively, use data binding. Results can be retrieved off of the 'result' property of the service itself. Always add fault handlers; you never know whether the connection will work.

Data binding: 

Data binding Use curly braces to bind ActionScript expressions to MXML attribute values. Not all attributes can be bound – use the [Bindable] metadata in order to make a member variable bindable. In beta 2, properties with getters and setters can also be made bindable through the same metadata.

Slide30: 


authorStream Live Help