<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Knowledge Supply Chain &#187; actionscript</title>
	<atom:link href="http://www.ipov.net/apps/blog/tag/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ipov.net/apps/blog</link>
	<description></description>
	<lastBuildDate>Fri, 17 Jun 2011 21:52:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Flash development with open source tools</title>
		<link>http://www.ipov.net/apps/blog/2009/09/flash-dev-environment-with-open-source-tools/</link>
		<comments>http://www.ipov.net/apps/blog/2009/09/flash-dev-environment-with-open-source-tools/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 03:33:30 +0000</pubDate>
		<dc:creator>joseph.gay</dc:creator>
				<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flashdevelop]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.ipov.net/blog/?p=94</guid>
		<description><![CDATA[A start to finish guide for setting up an Actionscript 3 development environment using open source tools that will work within the context of an agile process on Linux, or Windows.]]></description>
			<content:encoded><![CDATA[<p><strong>Why?</strong></p>
<ul>
<li><span style="background-color: #ffffff;">You want to do Flash work that is mostly development oriented. The environment described here will be useful for a programmer or small team using supplements from a designer as opposed to a designer working in the Flash IDE with supplements from a programmer.</span></li>
<li><span style="background-color: #ffffff;">You want a command line interface and a tool chain that can work easily with existing continuous integration and web deployment tools.</span></li>
</ul>
<p><span id="more-94"></span></p>
<p>The following steps will take you through the required set up for a sample project. There is a link to the full source at the end.</p>
<p><strong>Step 1: Download the Flex SDK</strong></p>
<p>Adobe&#8217;s open source <a title="Flex SDK 3 Download" href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3sdk">Flex SDK</a> provides, among other things, an Actionscript compiler binary: mxmlc. It&#8217;s not just useful for compiling mxml based Flex applications however; it can also be used to compile lightweight, pure Actionscript 3 projects. The download will consist of a single zip file which you may extract to a directory of your choice. On windows, I choose c:\flex, and on linux I choose /usr/local/share/adobe-flex/sdk. You&#8217;ll just need to remember the path when you set up your build environment. Note that for the compiler to work, you&#8217;ll need to have Java 1.6+ installed.</p>
<p><strong>Step 2: Download the Flash debugger standalone player and plugins</strong></p>
<p>Ok, so this part isn&#8217;t open source, but you can&#8217;t have Flash these days without Adobe&#8217;s Flash player. The <a title="Adobe Flash Downloads" href="http://www.adobe.com/support/flashplayer/downloads.html">debug flash player</a> will conveniently display a stack trace whenever there&#8217;s an error. The trace will even include line numbers if you build your swfs with the debug flag, which you will see how to do below. The debug enabled browser plugins are installed in the same manner as the normal browser plugins. If you&#8217;re running Windows, installing the ActiveX control will result in having a debug enabled player in IE. On both Linux and Windows, installing the &#8216;Plugin content debugger&#8217; will give you a debug enabled player in browsers like Firefox and Chrome. The standalone player can be placed anywhere. On Linux I&#8217;ve copied the flashplayer executable to /usr/local/bin, which is on my PATH.</p>
<p><strong>Step 3: Install Ant and the Flex SDK Ant tasks</strong></p>
<p>Since the Flex SDK internals are predominately written in Java, Ant is used as the build tool of choice for most Flex and Actionscript 3 projects. Accordingly, Adobe provides a set of Ant tasks for invoking various SDK related commands from within Ant. First <a title="Apache Ant home page" href="http://ant.apache.org">install Ant</a> (if you&#8217;re on a Linux system, you&#8217;re better off using your distribution&#8217;s package manager rather than Apache&#8217;s packages). Copy the file flexTasks.jar from &lt;flex sdk path&gt;/ant/lib to your Ant installation&#8217;s lib folder. On my Ubuntu Jaunty system for example, it was /usr/share/ant/lib. You will also copy from the flex Ant folder the file flexTasks.tasks to your project folder once it is created.</p>
<p><strong>Step 4: Choosing an editor/IDE</strong></p>
<p>Now that you can compile Actionscript files and view the results, you&#8217;ll need to select an Actionscript aware editor or IDE. If you are using Vim, there are a number of syntax files around the web. I&#8217;ve had luck with the ones found on <a href="http://www.abdulqabiz.com/blog/archives/2007/10/12/vim-actionscript-and-mxml-syntax-files/">Adbul Qabiz&#8217;s blog</a> for example. On Emacs, you will find what you need on the <a href="http://www.emacswiki.org">Emacs Wiki</a>, including some <a href="http://www.emacswiki.org/emacs/FlymakeActionscriptThree">FlyMake</a> code (build as you type). If you are running Windows, there is a tailored open source solution available: <a href="http://www.flashdevelop.org/wikidocs/index.php?title=Main_Page">FlashDevelop</a>. FlashDevelop provides IDE functionality for Actionscript 2 and 3, Flex, Air, and haXe. If you&#8217;re accustomed to Eclipse, Visual Studio, NetBeans, etc., you should feel right at home with FlashDevelop.</p>
<p><strong>Step 5: Creating a project template</strong></p>
<p>The main aim here is to build your project by issuing one command from the command line. You&#8217;ll start by creating a project folder, and inside the project folder you will create a file called build.xml for use with Ant. If you intend to collaborate with others on the project, it&#8217;s also a good idea to separate system specific variables into another file. At iPOV, we use a separate file called build-user.properties. Here are samples of both files:</p>
<pre class="brush: xml">&lt;project name="miniplayer" default="build-all" basedir="."&gt;
    &lt;description&gt;
           Builds iPOV Hello World
        To use, :
          1. Copy %flex_sdk_3%/ant/lib/flexTasks.jar  to %ANT_HOME%/lib
          2. Copy build-user.properties.default to build-user.properties
            (so it doesn't get commited to SVN) and
            edit the paths for your install.
          3. Invoke the build "&gt;ant [build-target-name]" (either via commandline of GUI launcher)
    &lt;/description&gt;

    &lt;!-- Import the property definitions. --&gt;
    &lt;property file="build-user.properties" /&gt;
    &lt;property name="PROJECT_NAME" value="ipov_hello-world"/&gt;
    &lt;property name="PROJECT_VERSION" value="1.0.0"/&gt;
    &lt;property name="DEPLOY_DIR" value="bin"/&gt;
    &lt;property name="MAIN_CLASS" value="src/net/ipov/hello_world/Main.as"/&gt;

    &lt;taskdef resource="flexTasks.tasks" classpath="${TASK_HOME}/flexTasks.jar" /&gt;

    &lt;target name="build-all" depends="build-swf,build-debug-swf"/&gt;

    &lt;target name="build-swf" depends="init"&gt;
        &lt;mxmlc file="${MAIN_CLASS}"
            output="${DEPLOY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.swf"
            debug="false" optimize="true" fork="true"
            default-background-color="0xffffff" &gt;
            &lt;source-path path-element="src/" /&gt;
        &lt;/mxmlc&gt;
    &lt;/target&gt;

    &lt;target name="build-debug-swf" depends="init"&gt;
        &lt;mxmlc file="${MAIN_CLASS}"
            output="${DEPLOY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.swf"
            debug="true" optimize="false" fork="true"
            default-background-color="0xffffff" &gt;
            &lt;source-path path-element="src/" /&gt;
        &lt;/mxmlc&gt;
    &lt;/target&gt;

    &lt;target name="init"&gt;
        &lt;mkdir dir="${DEPLOY_DIR}"/&gt;
    &lt;/target&gt;

&lt;/project&gt;<span style="background-color: #ffffff; font-size: small; "> </span></pre>
<pre class="brush: plain">#
# Copy this file to .user.properties and then edit it to match your system
#
FLEX_HOME=c:/flex3/sdk
TASK_HOME=c:/bin/apache-ant-1.7.1/lib</pre>
<p>Replace ipov_hello-world above with your project name, and replace the net/ipov path with the namespace you will use for your main source files.</p>
<p>If you are using FlashDevelop, you will now create a new AS3 project using Project -&gt; New Project. For Location, browse to your project folder where you have placed the two files above. For Package, type your primary namespace (net.ipov.hello_world in this example). FlashDevelop will create the necessary files and folders for you. Outside of FlashDevelop, you can simply create a folder called src, and inside place folders corresponding to your primary namespace. Then create a file called Main.as inside your primary namespace folder to act as the entry point for your application. Here the content of Main.as in the Hello, World! sample:</p>
<pre class="brush: as3">package net.ipov.hello_world
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.text.TextField;

    [SWF(height='300', width='400')]
    public class Main extends Sprite {

        private var _params:Object;

        public function Main():void {
            _params = root.loaderInfo.parameters ? root.loaderInfo.parameters : new Object();

            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);

        }

        private function init(e:Event = null):void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            var helloText:TextField = new TextField();
            helloText.text = "Hello, World!";
            stage.addChild(helloText);
        }

    }

}</pre>
<p>Once you have set up your project folder, invoke the following commands from the root of the project to build and launch the application:</p>
<pre class="brush: plain">~/projects/as3-hello-world $ ant
Buildfile: build.xml

init:

build-swf:
    [mxmlc] Loading configuration file /usr/local/share/adobe-flex/sdk/frameworks/flex-config.xml
    [mxmlc] /home/joseph/projects/as3-hello-world/build/ipov_hello-world-1.0.0.swf (833 bytes)

build-debug-swf:
    [mxmlc] Loading configuration file /usr/local/share/adobe-flex/sdk/frameworks/flex-config.xml
    [mxmlc] /home/joseph/projects/as3-hello-world/build/ipov_hello-world-1.0.0.swf (1021 bytes)

build-all:

BUILD SUCCESSFUL
Total time: 9 seconds
~/projects/as3-hello-world $ flashplayer build/ipov_hello-world-1.0.0.swf</pre>
<p>If you are using FlashDevelop, you can also use Project -&gt; Test Movie (F5 on the keyboard). When prompted to configure the compiler, set your Flex SDK location under AS3Context, and set the standalone Flash player location under FlashViewer.</p>
<p>That should be enough to get started developing AS3 applications. Future articles will include information about unit testing, continuous integration, deployment, and Adobe Captivate Widget development.</p>
<p><a href="http://www.ipov.net/blog/wp-content/uploads/2009/09/as3-hello-world.zip">as3-hello-world-source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ipov.net/apps/blog/2009/09/flash-dev-environment-with-open-source-tools/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

