Flex Introduction - 2

Dear All,
Sorry to bother.. but, I think this maybe useful for some people.

=========================
So, why Flex? In my personal opinion, Flex is more stable than JavaFX, which another product comes from Sun. Besides, Flex can be changed to AIR (stand-alone application which is kind of similar to Java Swing) very easily. Flex swf is compiled and run on Flash which is a Virtual Machine in your browser. Because of this VM, your Flex code (swf) files can run any most of browsers.
We will see more examples other than "Hello World" later.
Before we do the coding in Flex, you need to understand a little bit more about Flex. Basically, a Flex application is constructed by container(s) and component(s). One of the containers is "Application". In the "Hello World" example, I used "Application" type container.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
....
</mx:Application>

Of course, you can change the container type to something other than "Application". e.g. Box, Panel, Canvas, etc. Each container has its own uniqueness. You need to understand the differences and make your own decision to see what's the best for you. In the Flex SDK, there are some examples you can see and compare. Please note, you will need to have at least one "Application" container as the "root" container for each application. A container can include container(s), too.
If you ran the example "Hello World" I gave you, you may notice the "Hello World" label is on the upper-left corner of the screen. This is because you can specify the layout. In the "Hello World" example, we had layout='absolute' and that's why the label is on the upper-left. Now, let's see the following example.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Panel>
<mx:Label id="myLabel" text="Hello World" />
</mx:Panel>
</mx:Application>

By running the example, you will find out the "Hello World" is now in the middle of your browser no matter how you resize your browser. Also, as I previous mentioned, you can have one container includes one or more containers.

So, you may say I can do the same thing for JSP, HTML, ASP, PHP, etc. Why Flex? Later on, I will provide more complex coding and you will know why..

Thanks,

Nelson