Chad's Blog

Hello World, Flex

Posted by Chad Hendry on 15 Sep 2009

I created my first Flex application today and it was remarkably painless. Here’s how:

First download and install the Flex 3 SDK. Unzip it anywhere and add the bin subdirectory to your path.

Next create a file called hello.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
  <![CDATA[
    import mx.controls.Alert;
  ]]>
  </mx:Script>
  <mx:Button id="button" label="Hello, World!"
      click="Alert.show('hi!')" />
</mx:Application>

Then compile it using mxmlc:

Next, embed the compiled .swf file in a webpage using the following HTML:

<html>
  <head>
    <title>Chad's First Flash Application</title>
  </head>
  <body>
    <object type="application/x-shockwave/flash" data="hello.swf"
        width="200" height="200" />
  </body>
</html>

Here’s the result:

geico ringtone loop
stop!