<?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>Coding Friends &#187; mxmlc</title>
	<atom:link href="http://www.codingfriends.com/index.php/tag/mxmlc/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codingfriends.com</link>
	<description>Coding Friends, place for developers.</description>
	<lastBuildDate>Sun, 04 Dec 2011 21:11:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Hello World</title>
		<link>http://www.codingfriends.com/index.php/2010/02/01/hello-world-8/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hello-world-8</link>
		<comments>http://www.codingfriends.com/index.php/2010/02/01/hello-world-8/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 20:21:56 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Flex Flash]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[mxmlc]]></category>
		<category><![CDATA[swf]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=626</guid>
		<description><![CDATA[Flex is the Flash SDK from Adobe, you can download a open source command line compiler from adobe (Flex open source page ). The Free SDK link is here. Once you have downloaded the free SDK, you will need to place into the system. I have placed mine into /opt directory called flex_sdk_3, so something [...]]]></description>
			<content:encoded><![CDATA[<p>Flex is the Flash SDK from Adobe, you can download a open source command line compiler from adobe (<a href="http://www.adobe.com/products/flex/">Flex open source page</a> ).   The Free SDK link is <a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3sdk">here</a>.</p>
<p>Once you have downloaded the free SDK, you will need to place into the system. I have placed mine into /opt directory called flex_sdk_3, so something like (you will need to be root to do this!)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> flex_sdk_3
<span style="color: #7a0874; font-weight: bold;">cd</span> flex_sdk_3
<span style="color: #c20cb9; font-weight: bold;">unzip</span> <span style="color: #000000; font-weight: bold;">&lt;</span>place where your <span style="color: #c20cb9; font-weight: bold;">free</span> sdk is<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>and then create a place for where you are going to be creating your flex scripts, I placed mine into my home directory under my programming/flex sturcture, so this is where I am</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> ~<span style="color: #000000; font-weight: bold;">/</span>Programming<span style="color: #000000; font-weight: bold;">/</span>flex<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>The -p will create any directories that are not present there already, and also the ~ is for the home directory that user.</p>
<p>I then copied the flex-config.xml from the /opt/flex_sdk_3/frameworks directory into the Programming/flex directory and edited it to the new values.<br />
The full differences between the standard flex-config.xml and the one that I have altered is below, but basically I have added into the xml elements values the new directory for where flex-sdk is (e.g. /opt/flex_sdk_3/) so that flex&#8217;s command line environment will know where to get the libraries to compile and create the swf (ShockWave Flash), but here are the elements that I have altered.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;external-library-path<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path-element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/opt/flex_sdk_3/frameworks 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;library-path<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     all the <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path-element</span><span style="color: #ff0000;">'s&gt;</span></span>/opt/flex_sdk_3/frameworks
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;namespaces<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   the <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;manifest<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/opt/flex_sdk_3/frameworks path to the framework directory file.</pre></div></div>

<p>Because the class structure follows the directory structure of the directories below the compiling environment, I created the following directory structure com/codingfriends/helloworld with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> com<span style="color: #000000; font-weight: bold;">/</span>codingfriends<span style="color: #000000; font-weight: bold;">/</span>helloworld</pre></div></div>

<p>which will create the whole structure if there is no directories there already.</p>
<p>Then you can place these two files into the helloworld directory</p>
<p>This is the class Greeter that is created and turned into a object within the swf file save this as Greeter.as</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// the directory structure of where the class is.</span>
package com.<span style="color: #007788;">codingfriends</span>.<span style="color: #007788;">helloworld</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> Greeter
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">private</span> var name<span style="color: #008080;">:</span>String<span style="color: #008080;">;</span>
&nbsp;
		<span style="color: #666666;">// constructor</span>
		<span style="color: #0000ff;">public</span> function Greeter<span style="color: #008000;">&#40;</span>initialName<span style="color: #008080;">:</span>String<span style="color: #000080;">=</span><span style="color: #FF0000;">&quot;Ian&quot;</span><span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			name <span style="color: #000080;">=</span> initialName<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
&nbsp;
		<span style="color: #666666;">// sayHello returns a String</span>
		<span style="color: #0000ff;">public</span> function sayHello<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">:</span>String
		<span style="color: #008000;">&#123;</span>
			var result<span style="color: #008080;">:</span>String<span style="color: #008080;">;</span>
			<span style="color: #666666;">// if the class private name is present</span>
			<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>name<span style="color: #000040;">!</span><span style="color: #000080;">=</span>null <span style="color: #000040;">&amp;&amp;</span> name.<span style="color: #007788;">length</span> <span style="color: #000080;">&gt;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>	
			<span style="color: #008000;">&#123;</span>
				result <span style="color: #000080;">=</span> <span style="color: #FF0000;">&quot;Hello there, &quot;</span><span style="color: #000040;">+</span>name<span style="color: #000040;">+</span><span style="color: #FF0000;">&quot;.&quot;</span><span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
			<span style="color: #666666;">// should never reach here on a basic run.</span>
			<span style="color: #0000ff;">else</span> 
			<span style="color: #008000;">&#123;</span>
				result<span style="color: #000080;">=</span><span style="color: #FF0000;">&quot;Hello there.&quot;</span><span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
&nbsp;
			<span style="color: #0000ff;">return</span> result<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>var = variable and the type of variable or return variable is at the end of the definition e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">public</span> var name<span style="color: #008080;">:</span>String<span style="color: #008080;">;</span> <span style="color: #666666;">// this is a variable named &quot;name&quot; and it is of type String</span>
<span style="color: #0000ff;">public</span> function sayHello<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">:</span>String <span style="color: #666666;">// this is a function named &quot;sayHello&quot; and returns a String type</span></pre></div></div>

<p>save this as Greeter_mx.mxml</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Application</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;absolute&quot;</span> <span style="color: #000066;">initialize</span>=<span style="color: #ff0000;">&quot;initApp();&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">import com.codingfriends.helloworld.Greeter;</span>
<span style="color: #339933;">// the initialize application .. the start</span>
<span style="color: #339933;">private function initApp():void</span>
<span style="color: #339933;">{</span>
<span style="color: #339933;">	// create a new Greeter object with no passing in name</span>
<span style="color: #339933;">	var myGreeter:Greeter = new Greeter();</span>
<span style="color: #339933;">	// and say hello world </span>
<span style="color: #339933;">	output.text+=myGreeter.sayHello();</span>
<span style="color: #339933;">	// create a new greeter with the name = genux instead</span>
<span style="color: #339933;">	var newGreeter:Greeter = new Greeter(&quot;genux&quot;);</span>
<span style="color: #339933;">	output.text+=newGreeter.sayHello();</span>
<span style="color: #339933;">}</span>
<span style="color: #339933;">]]&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Text</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;output&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #000066;">textAlign</span>=<span style="color: #ff0000;">&quot;center&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The <mx:Script> is the place where the code starts, the rest is just the adobe application settings, within the code there is a reference to &#8220;output&#8221;, which is defined in the <mx:Text xml element for the application code.  The code will create a new Greeter class from the Greeter.as file above and then add the output from the sayHello() function to the output mx:Text element.</p>
<p>When you want to compile up the source code, you will need to add the /opt/flex_sdk_3/bin (which is where the mxmlc command line compiler for creating the swf file) to the console</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>flex_sdk_3<span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

<p>and then to compile up the source code</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mxmlc <span style="color: #660033;">-load-config</span> flex-config.xml <span style="color: #660033;">-source-path</span>=~<span style="color: #000000; font-weight: bold;">/</span>Programming<span style="color: #000000; font-weight: bold;">/</span>flex<span style="color: #000000; font-weight: bold;">/</span>actionscript<span style="color: #000000; font-weight: bold;">/</span> .<span style="color: #000000; font-weight: bold;">/</span>com<span style="color: #000000; font-weight: bold;">/</span>codingfriends<span style="color: #000000; font-weight: bold;">/</span>helloworld<span style="color: #000000; font-weight: bold;">/</span>Greeter_mx.mxml <span style="color: #660033;">-output</span> .<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>Greeter_mx.swf</pre></div></div>

<p>the -load-config will load the one in the present directory which I altered, and -source-path is there so that the base directory is used for compiling so the compiler will know where to get the com/codingfriends/helloworld/Greeter.as and Greeter_mx.mxml, and the -output is what the output flash file is/placed.</p>
<p>Here is the output of the Greeter.swf file.</p>
<p><embed src="/swf/Greeter_mx.swf" width="250" height="50"><br />
</embed></p>
<p>Here is the difference (diff) between the flex-config.xml from the one that I edited and the one that was in the /opt/flex_sdk_3/frameworks directory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">53c53
<span style="color: #000000; font-weight: bold;">&lt;</span>           <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;/</span>opt<span style="color: #000000; font-weight: bold;">/</span>flex_sdk_3<span style="color: #000000; font-weight: bold;">/</span>frameworks<span style="color: #000000; font-weight: bold;">/</span>libs<span style="color: #000000; font-weight: bold;">/</span>player<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>targetPlayerMajorVersion<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>playerglobal.swc<span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #660033;">---</span>
<span style="color: #000000; font-weight: bold;">&gt;</span>           <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>libs<span style="color: #000000; font-weight: bold;">/</span>player<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>targetPlayerMajorVersion<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>playerglobal.swc<span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
70c70
<span style="color: #000000; font-weight: bold;">&lt;</span>          <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;/</span>opt<span style="color: #000000; font-weight: bold;">/</span>flex_sdk_3<span style="color: #000000; font-weight: bold;">/</span>frameworks<span style="color: #000000; font-weight: bold;">/</span>libs<span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #660033;">---</span>
<span style="color: #000000; font-weight: bold;">&gt;</span>          <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>libs<span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000;">72</span>,74c72,<span style="color: #000000;">74</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>          <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;/</span>opt<span style="color: #000000; font-weight: bold;">/</span>flex_sdk_3<span style="color: #000000; font-weight: bold;">/</span>frameworks<span style="color: #000000; font-weight: bold;">/</span>libs<span style="color: #000000; font-weight: bold;">/</span>player<span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>          <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;/</span>opt<span style="color: #000000; font-weight: bold;">/</span>flex_sdk_3<span style="color: #000000; font-weight: bold;">/</span>frameworks<span style="color: #000000; font-weight: bold;">/</span>libs<span style="color: #000000; font-weight: bold;">/</span>player<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>targetPlayerMajorVersion<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>            <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;/</span>opt<span style="color: #000000; font-weight: bold;">/</span>flex_sdk_3<span style="color: #000000; font-weight: bold;">/</span>frameworks<span style="color: #000000; font-weight: bold;">/</span>locale<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>locale<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #660033;">---</span>
<span style="color: #000000; font-weight: bold;">&gt;</span>          <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>libs<span style="color: #000000; font-weight: bold;">/</span>player<span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&gt;</span>          <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>libs<span style="color: #000000; font-weight: bold;">/</span>player<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>targetPlayerMajorVersion<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&gt;</span>            <span style="color: #000000; font-weight: bold;">&lt;</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>locale<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>locale<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">&lt;/</span>path-element<span style="color: #000000; font-weight: bold;">&gt;</span>
82c82
<span style="color: #000000; font-weight: bold;">&lt;</span>             <span style="color: #000000; font-weight: bold;">&lt;</span>manifest<span style="color: #000000; font-weight: bold;">&gt;/</span>opt<span style="color: #000000; font-weight: bold;">/</span>flex_sdk_3<span style="color: #000000; font-weight: bold;">/</span>frameworks<span style="color: #000000; font-weight: bold;">/</span>mxml-manifest.xml<span style="color: #000000; font-weight: bold;">&lt;/</span>manifest<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #660033;">---</span>
<span style="color: #000000; font-weight: bold;">&gt;</span>             <span style="color: #000000; font-weight: bold;">&lt;</span>manifest<span style="color: #000000; font-weight: bold;">&gt;</span>mxml-manifest.xml<span style="color: #000000; font-weight: bold;">&lt;/</span>manifest<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2010/02/01/hello-world-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

