organic thoughts

seemingly random and unorgainzed bits of information

10.13.2006

Getting Started with Flex 2

Starting with Flex should be a familiar endeavor to all Java developers.
  1. Download SDK (requires registration)

  2. Unzip SDK to a location of your choice [FLEX_HOME]

    Add your FLEX_HOME/bin location to your system's PATH.

  3. Write your code

  4. Compile using mxmlc Flex compiler

  5. Deploy.

Your First Flex – Hello Flex

  1. Open your favorite IDE (TextPad, NotePad, Eclipse, NetBeans, etc).

  2. Create a new text document (must use the .mxml extension when saved)

  3. Type the following:


    <mx:Application width="100%" height="100%"
    xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="middle">

    <mx:Script><![CDATA[
    import mx.controls.Alert;
    ]]>
    </mx:Script>

    <mx:Panel id="panel" title="Hello Flex">
    <mx:Form width="100%">
    <mx:FormItem label="Enter Name:">
    <mx:TextInput id="myName" text=""/>
    </mx:FormItem>
    </mx:Form>

    <mx:ControlBar horizontalAlign="center">
    <mx:Button id="btn" label="Say Hello" click="Alert.show('Hello ' + myName.text);"/>
    </mx:ControlBar>
    </mx:Panel>
    </mx:Application>

    3. Save file as 'helloflex.mxml'
  4. Compile Code to generate swf file

    $> mxmlc -file-specs helloflex.mxml

  5. Deploy the Flash file

    Open file helloflex.swf in your browser.

Click here to see helloflex.swf.

The Details
Flex uses a code-compile-deploy model similar to Java development. You write your GUI layout structure using Flex's declarative XML-based language 'MXML'. Flex also uses ActionScript, a true object oriented derivative of ECMAScript (also know as standard JavaScript). When you compile your code, Flex's mxmlc compiler transform the XML file into pure ActionScript then compile it into Flash byte code (.SWF).

Next posts we will look at Flex from a Java developer's perspective.






<< Home

This page is powered by Blogger. Isn't yours?