RIA & Adobe Flex

34
RIA & Adobe Flex Yunhui Fu 11/05/2008

description

RIA & Adobe Flex. Yunhui Fu 11/05/2008. What’s RIA. RIA (Rich Internet Applications) web applications which look and perform like desktop applications. What’s RIA. RIA (Rich Internet Applications) web applications which look and perform like desktop applications. Some examples: - PowerPoint PPT Presentation

Transcript of RIA & Adobe Flex

Page 1: RIA & Adobe Flex

RIA & Adobe Flex

Yunhui Fu

11/05/2008

Page 2: RIA & Adobe Flex

What’s RIA

• RIA (Rich Internet Applications)– web applications which look and perform like

desktop applications.

Page 3: RIA & Adobe Flex

What’s RIA

• RIA (Rich Internet Applications)– web applications which look and perform like

desktop applications.

• Some examples:– Google map (http://maps.google.com/)– Yahoo map (http://maps.yahoo.com/)– Youtube (http://www.youtube.com/)

Page 4: RIA & Adobe Flex

RIA Tech

• Two type of techonologies– Javascript

• AJAX – supported by browser• Toolkits

– Open source: jQuery, Prototype, script.aculo.us, Mootools, Dojo– Google AJAX API– Yahoo! User Interface Library (YUI)– ASP.NET AJAX

– Plug-ins• Installation – virtual machine• Toolkits

– Java, JavaFX– Flash, Flex– Silverlight

Page 5: RIA & Adobe Flex

RIA Tech - JavaFX

• Sun Microsystems

• Design tool: NetBean

• Java one meeting, May 2007

• Not available until 2009

• Open source? compiler

• http://www.sun.com/software/javafx/

Page 6: RIA & Adobe Flex

RIA Tech - Curl

• Curl – subsidiary of Sumisho Computer Systems

• Design tool: Curl 6.0

• First release: 2002

• Free for personal use; Deployment License is needed.

• http://www.curl.com/

Page 7: RIA & Adobe Flex

RIA Tech - SilverLight

• Microsoft

• Design tool: Visual Studio / Blend

• CTP version: 11/2006

• Commercial

• http://www.microsoft.com/silverlight/

Page 8: RIA & Adobe Flex

RIA Tech - Flex

• Macromedia -> Adobe

• Design tool: Flex Builder

• Flex 1.0: 2004

• http://www.adobe.com/devnet/flex/

Page 9: RIA & Adobe Flex

What’s Flex

• A method to develop the swf• A tool of the programmer• Flex applications are rendered using Flash

Player 9• Flex applications are written using MXML and/or

ActionScript– MXML: XML-based markup language, layout display

elements– ActionScript : ECMAScript-compliant object-oriented

programming language, application logic.– MXML and ActionScript code are compiled into binary

SWF files.

Page 10: RIA & Adobe Flex

Flex examples

• MINI car Configurator: http://www.miniusa.com/?#/build/configurator/mini_clubs-m

• Adobe’s Buzzword project : http://buzzword.acrobat.com/

Page 11: RIA & Adobe Flex

Flex Builder

• IDE (Integrated Development Environment)

• Base on Eclipse IDE (An open source IDE)

• Integrate design, debug

Page 12: RIA & Adobe Flex

Flex Builder - Installation

• Flex Builder 3 Professional

• Windows & Macintosh Version

• Download: http://www.adobe.com/support/flex/

Page 13: RIA & Adobe Flex

Create a simple app 1

• Basic Concepts– MXML: Layout– ActionScript : application logic

Page 14: RIA & Adobe Flex

MXML – The root element

<mx:Application>

Page 15: RIA & Adobe Flex

MXML - Components

<mx:Application> <mx:WebService id=“ws” wsdl=“catalog.wsdl”/> <mx:Button label=“Get Data”

click=“ws.getProducts()”/> <mx:DataGrid dataProvider=“{ws.getProducts…}”/> <mx:LineChart dataProvider=“{ws.getProducts….}”/></mx:Application>

Page 16: RIA & Adobe Flex

MXML - ID

<mx:Application> <mx:WebService id=“ws” wsdl=“catalog.wsdl”/> <mx:Button label=“Get Data”

click=“ws.getProducts()”/> <mx:DataGrid dataProvider=“{ws.getProducts…}”/> <mx:LineChart dataProvider=“{ws.getProducts….}”/></mx:Application>

Page 17: RIA & Adobe Flex

MXML - Attributes

<Application> <WebService id=“ws” wsdl=“catalog.wsdl”/> <Button label=“Get Data” click=“ws.getProducts()”/> <DataGrid dataProvider=“{ws.getProducts…}”/> <LineChart dataProvider=“{ws.getProducts….}”/></Application>

Page 18: RIA & Adobe Flex

Create a simple app 2

• Application: FlickrRIA

• flickr.com

Page 19: RIA & Adobe Flex

Create a simple app 3

Page 20: RIA & Adobe Flex

Create a simple app 4

• Create a new project

• Flex Builder IDE– File->New->Flex Project: (name) FlickrRIA– (Application Type) Web Application + Server

Technology– Finish

FlickrRIA.mxml is created

Page 21: RIA & Adobe Flex

Create a simple app 5

• Delete layout=“absolute”

• Add:– backroundGradientColors=“left”– horizontalAlign="left“– verticalGap="15" horizontalGap="15"

Page 22: RIA & Adobe Flex

Create a simple app 6

• Click “Design” button to switch to design mode

• Add Component: HBox• Add Label• Add TextInput• Add Button

Page 23: RIA & Adobe Flex

Create a simple app 7

• Add HTTPService object

• Use HTTPService to call Flickr service and return results

• Add id=“photoService”• Add url=“http://api.flickr.com/services/feeds/photos_public.gne”

• Add result=“photoHandler(event)

Page 24: RIA & Adobe Flex

Create a simple app 8

• Create a bindable XML variable in ActionScript<mx:Script>

<![CDATA[]]>

</mx:Script>• Add

– import mx.collections.ArrayCollection;– import mx.rpc.events.ResultEvent;

• Add bindable private variable– [Bindable]– private var photoFeed: ArrayCollection;

Page 25: RIA & Adobe Flex

Create a simple app 9• Create submit button click handler• Add button’s attribute:

– click="requestPhotos()"• Add TextInput’s id:

– id="searchTerms"• Add function requestPhotos()

private function requestPhotos () : void { photoService.cancel (); var params:Object = new Object (); params.format = 'rss_200_enc'; params.tags = searchTerms.text; photoService.send (params);}

Page 26: RIA & Adobe Flex

Create a simple app 10

• Add HTTPService result handler – photoHandler()

private function photoHandler (event:ResultEvent) :void{

photoFeed = event.result.rss.channel.item as ArrayCollection;

}

.

Page 27: RIA & Adobe Flex

Create a simple app 11-a• Add TileList component to display the images<mx:TileList width="100%“ height="100%"></mx:TileList>

• Add TileList‘s attribute:dataProvider="{photoFeed}

• Add TileList‘s property:<mx:itemRenderer></mx:itemRenderer>

• Add itemRenderer‘s property:<mx:Component></mx:Component>

Page 28: RIA & Adobe Flex

Create a simple app 11-b

• Add VBox in Component:<mx:VBox width="125" height="125" paddingBottom="5" paddingLeft="5" paddingTop="5" paddingRight="5">

</mx:VBox>

• Add Image & Text in Vbox:<mx:Image width="75" height="75" source="{data.thumbnail.url}" />

<mx:Text text="{data.credit}" />

Page 29: RIA & Adobe Flex

Create a simple app 12

• Run!

Page 30: RIA & Adobe Flex

Connecting to server

• Flex provides a rich set of web service tools• POST & PUT• HTTP request

– Similar to Ajax– asynchronously

• SOAP services, Simple Object Access Protocol– A set of Flex classes

• Remote object– Server side: support AMF requests

• Socket– Any protocol

Page 31: RIA & Adobe Flex

HTTPService tag• <?xml version="1.0" encoding="utf-8"?>• <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">• <mx:HTTPService id="srv" url="http://localhost/formtest.php" method="POST“• result="mx.controls.Alert.show (srv.lastResult.toString());">• <mx:request>• <first>{first.text}</first>• <last>{last.text}</last>• <email>{email.text}</email>• </mx:request>• </mx:HTTPService>• <mx:Form>• <mx:FormItem label="First Name">• <mx:TextInput id="first"/>• </mx:FormItem>• <mx:FormItem label="Last Name">• <mx:TextInput id="last"/>• </mx:FormItem>• <mx:FormItem label="Email">• <mx:TextInput id="email"/>• </mx:FormItem>• <mx:FormItem>• <mx:Button label="Subscribe" click="srv.send()"/>• </mx:FormItem>• </mx:Form>• </mx:Application>

Page 32: RIA & Adobe Flex

Another Example

• Video (10’): http://www.adobe.com/products/flex/media/flexapp/

Page 33: RIA & Adobe Flex

Reference

• Jack Herrington and Emily Kim, Getting Started with Flex™ 3

• MINI car Configurator: http://www.miniusa.com/?#/build/configurator/mini_clubs-m

• Adobe’s Buzzword project : http://buzzword.acrobat.com/

• Google map: http://maps.google.com/• Yahoo map: http://maps.yahoo.com/• Youtube: http://www.youtube.com/

Page 34: RIA & Adobe Flex

Thanks!