»
S
I
D
E
B
A
R
«
Setup and Develop Flex SDK 3.5 on Linux
January 24th, 2010 by admin

To people who can’t afford to buy Flash or Flex Builder, there is free version of Flex SDK available.

To setup and develop Flex SDK 3.5 on Linux is fairly easy.

1. Download Flex SDK 3.5

http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3sdk

2. Extract Flex SDK 3.5 to /opt/flex_sdk_3.5

3. Add /opt/flex_sdk_3.5/bin and /opt/flex_sdk_3.5 to environment path variable

First fire up your command line tool, and execute the following command:
sudo gedit ~/.bashrc

Then add the following lines to the end of the file
export PATH=/opt/flex_sdk_3.5/bin:$PATH
export FLEX_SDK_HOME=/opt/flex_sdk_3.5

4. Create project folder in workspace, for my case, I use /home/shichuan/workspace/flex/ with project name: actionscript

The final directory structure is:
/home/shichuan/workspace/flex/actionscript/
/home/shichuan/workspace/flex/actionscript/src/
/home/shichuan/workspace/flex/actionscript/bin/

5. Copy flex-config.xml from FLEX_SDK_HOME/frameworks to /home/shichuan/workspace/flex/actionscript/flex-config.xml

cp $flex_sdk_home/frameworks/flex-config.xml /home/shichuan/workspace/flex/actionscript/flex-config.xml

6. Edit $flex_sdk_home/frameworks/flex-config.xml

gedit $flex_sdk_home/frameworks/flex-config.xml

Uncomment the source-path element, and add a path-element child in the source-path element, which points to the root src folder of our project.

/home/shichuan/workspace/flex/actionscript/src/

7. Edit /home/shichuan/workspace/flex/actionscript/flex-config.xml

change the following portion

<!-- List of SWC files or directories to compile against but to omit from -->

      <!-- linking.                                                             -->

      <external-library-path>

          <path-element>libs/player/{targetPlayerMajorVersion}/playerglobal.swc</path-element>

      </external-library-path>

      <!-- Turn on writing of generated/*.as files to disk. These files are generated by -->

      <!-- the compiler during mxml translation and are helpful with understanding and   -->

      <!-- debugging Flex applications.                                                  -->

      <keep-generated-actionscript>false</keep-generated-actionscript>

      <!-- not set -->

      <!--

      <include-libraries>

         <library>string</library>

      </include-libraries>

      -->

      <!-- List of SWC files or directories that contain SWC files. -->

      <library-path>

         <path-element>libs</path-element>   

		 <!-- keep the original location in the libpath for backwards-compatibility -->

         <path-element>libs/player</path-element>

         <path-element>libs/player/{targetPlayerMajorVersion}</path-element>    

	     <path-element>locale/{locale}</path-element>

      </library-path>

      <namespaces>

      <!-- Specify a URI to associate with a manifest of components for use as MXML -->

      <!-- elements.                                                                -->

         <namespace>

            <uri>http://www.adobe.com/2006/mxml</uri>

            <manifest>mxml-manifest.xml</manifest>

         </namespace>

      </namespaces>

to:

<!-- List of SWC files or directories to compile against but to omit from -->

      <!-- linking.                                                             -->

      <external-library-path>

          <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}/playerglobal.swc</path-element>

      </external-library-path>

      <!-- Turn on writing of generated/*.as files to disk. These files are generated by -->

      <!-- the compiler during mxml translation and are helpful with understanding and   -->

      <!-- debugging Flex applications.                                                  -->

      <keep-generated-actionscript>false</keep-generated-actionscript>

      <!-- not set -->

      <!--

      <include-libraries>

         <library>string</library>

      </include-libraries>

      -->

      <!-- List of SWC files or directories that contain SWC files. -->

      <library-path>

         <path-element>${flexlib}/libs</path-element>   

		 <!-- keep the original location in the libpath for backwards-compatibility -->

         <path-element>${flexlib}/libs/player</path-element>

         <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}</path-element>    

	     <path-element>${flexlib}/locale/{locale}</path-element>

      </library-path>

      <namespaces>

      <!-- Specify a URI to associate with a manifest of components for use as MXML -->

      <!-- elements.                                                                -->

         <namespace>

            <uri>http://www.adobe.com/2006/mxml</uri>

            <manifest>${flexlib}/mxml-manifest.xml</manifest>

         </namespace>

      </namespaces>

8. Create actionscript file: /home/shichuan/workspace/flex/actionscript/src/com/example/quickstart/Greeter.as

package com.example.quickstart
{
public class Greeter
{
public var name:String;
private var secretValue:Number;

public function Greeter(initialName:String=”Agus”)
{
name = initialName;
}

public function sayHello():String
{
var result:String;
if(name!=null && name.length>0){
result = “Hello there, “+name+”.”;
}
else{
result=”Hello there, anonymous.”;
}
return result;
}
}
}

9. Create mxml file: /home/shichuan/workspace/flex/actionscript/com/example/quickstart/Greeter_mx.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="initApp();">
<mx:Script>
<![CDATA[
import com.example.quickstart.Greeter;
private function initApp():void{
var myGreeter:Greeter = new Greeter();
output.text=myGreeter.sayHello();
output.text+="n";
myGreeter.name="Harold";
output.text += myGreeter.sayHello();
}

]]>
</mx:Script>

<mx:Text id="output" width="100%" textAlign="center"/>

</mx:Application>

9. Create a file /home/shichuan/workspace/flex/actionscript/compile

#!/bin/bash
mxmlc -load-config flex-config.xml ./src/com/example/quickstart/Greeter_mx.mxml -output ./bin/Greeter_mx.swf

10. run the compile shell script:

./compile

To test the example swf:
Open /home/shichuan/com/example/quickstart/Greeter_mx.swf in Firefox

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay



Similar Posts:
Leave a Reply

Powered by WP Hashcash