Before everything else I wanted to layout things. I had a trial version of Flex Builder with me. Designing the layout with Flex Builder is very easy. I can simply drag and drop components and create the layout. But I wanted to use IntelliJ IDEA as my IED. The main draw back for using Idea was been not able to preview the layout in design time. The solution to this problem came in two parts.
1 Design the site in relative layout
2 Use Flex component explorer as a reference (http://www.adobe.com/devnet/flex/tourdeflex/web/)
All most all the tutorials out there explains how to create absolute layouts. This is ok when we have Flex builder. But when we are not with this tool, it's not easy to visualize the layout when we create absolute layouts.
So I experimented with relative layouts in “mxml”. It is almost the same as html/css relative layouts. You simply have to make sure layout=”horizontal” or layout=“vertical” is set in the Application tag in the main mxml file. Then we can use “HBox” components to float content horizontally and “VBox” components to float content vertically. And also you can have an external css file linked to this main mxml application and control the look and feel from there by assigning style classes to components. But I must say that we don't have complete control over each components through the style sheet. There are limitations. “http://www.loscavio.com/downloads/blog/flex3_css_list/flex3_css_list.htm” is a good reference on what styles can be use on which components. Of cause you can always refer to the API documentation as well.
<div>
<div style=”float:right”>column 01</div><div style=”float:right”> column 02</div>
</div>
<div>
next row test content
</div>
The above code displays a layout with two columns with “column 01” and “column 02” in one row and “next row test content” in the second row. We can achive the same in mxml as follows.
<mx:vbox>
<mx:hbox><mx:text>column 01</mx:text><mx:text>column 02</mx:text></mx:hbox>
<mx:text>next row test content</mx:text>
</mx:vbox>
When you grab the experience on how to layout content relatively you can use what ever IDE you prefer to develop your Flex application. Also you can use Flex Ant tasks and write an Ant build script to build the application and wrap it in in a html wrapper. I will be able to explain how to do these later with several other blog posts.
Comments