Saturday, March 27, 2010

Using the Open Source Flex SDK

I'd like to do some Flex development without Flexbuilder. Here's how I got the open source SDK working in Ubuntu Linux:

Installing:
Download the SDK from the download page. Unzip its contents to ~/opt/flex as follows:
cd ~/Downloads
unzip flex_sdk_4.zip -d ~/opt/flex
Add the Flex bin directory to your PATH:
echo "PATH=\$PATH:\$HOME/opt/flex/bin" >> ~/.bashrc
restart your terminal. Now you should have the mxmlc command and other Flex command line tools available:

Writing Hello World:
<html>
<head>
<style type="text/css">
<!--
body {
height: 100%;
width: 100%;
margin: 0;
}
-->
</style>
</head>
<body>
<object width="550" height="400">
<param name="movie" value="hello.swf">
<embed src="hello.swf" width="100%" height="100%">
</embed>
</object>
</body>
</html>
Here we have a typical HTML page for displaying a .swf file. And below is a "Hello World" mxml file.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Label text="Hello World!"/>
</mx:Application>

You can download, compile, and run these files as follows:
wget http://www.curransoft.com/code/hello/hello.mxml http://www.curransoft.com/code/hello/hello.html
mxmlc hello.mxml
firefox hello.html

There you go!

0 comments: