Pragmatic Programmer Issues

Flex2 on the board

Comments: 1

Today my family went to kids-play. The children has unimaginable power. My wife is sleeping now, and I’m nearly sleeping too.

Introduction to Flex

Flex is based on adobe flash technology. Flex applications consist of MXML and ActionScript source files. For easy development you can try for 30 days Flex Builder. Flex Builder is built on Eclipse so everyone who use eclipse is familiar with. There are also Flex Data Service (integration with EJB, Hibernte, JMS and other data sources) and Flex Charting (charts).

The one hour ride on Flex.

Creating application is easy part. You have graphical designer where you layout components. It’s very similar to Swing application building. There is also event-listener mechanism. All properties You can set by properties editor, it’s very comfortable.

The heart of every application is MXML file. This is a normal XML file, which flex can convert on the fly to swf. The flex builder has very good mxml editor, it provides hints and auto-completes your code. Builder has a very good debuger, so you can easy debug your code to find out what’s going on.

You can create customer components and reuse it whenever you need. I think that you can find useful components on the web.

And finally flex has many WebService/XML integration. It’s very easy to create application connection to WS. For example, this code is a flex blogger reader from tutorial. This application connect to flex blog, read last post and shows them in table view.

The code:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”
layout=”absolute” creationComplete=”feeder.send()”>
<mx:HTTPService
id=”feeder”
url=”http://weblogs.macromedia.com/mchotin/index.xml”
useProxy=”false”/>
<mx:Panel title=”{feeder.lastResult.rss.channel.title}” x=”10″ y=”10″ width=”475″ height=”400″ layout=”absolute” >
<mx:DataGrid x=”20″ y=”20″ id=”posts” width=”400″
dataProvider=”{feeder.lastResult.rss.channel.item}“>
<mx:columns>
<mx:DataGridColumn headerText=”Posts” dataField=”title”/>
<mx:DataGridColumn headerText=”Date” dataField=”pubDate” width=”150″/>
</mx:columns>
</mx:DataGrid>
<mx:TextArea x=”20″ y=”175″ width=”400″ htmlText=”{posts.selectedItem.description}”/>
<mx:LinkButton x=”20″ y=”225″ label=”Read Full Post”
click=”navigateToURL(new URLRequest(posts.selectedItem.link));”/>
</mx:Panel>
</mx:Application>

The HTTPService object is responsible for getting posts. It simple get HTML page. Next we can access DOM objects. In our example rss.channel.title and channel.item (this one is a collection). It’s very easy.

Summary of Flex

+ Rich user interface
+ Eliminate page loads
– Depends on Adobe Flash 9
– Flex Builder is not free, building without builder is not easy than.

Categories

Comments

Aleksander BienkowskiAleksander Bienkowski

It’s good for effective web pages. 30 days of trial version its enough time to write very nice web page with some java logic. So maybe its worthy to get involved whith it.