<?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>One Little Robot &#187; Flex</title>
	<atom:link href="http://www.onelittlerobot.co.uk/tag/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.onelittlerobot.co.uk</link>
	<description>Flash, Flex and PHP</description>
	<lastBuildDate>Mon, 13 Jun 2011 19:42:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Actionscript Ant Tool</title>
		<link>http://www.onelittlerobot.co.uk/2010/08/07/actionscript-ant-tool-part-1/</link>
		<comments>http://www.onelittlerobot.co.uk/2010/08/07/actionscript-ant-tool-part-1/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 19:20:11 +0000</pubDate>
		<dc:creator>Kevin Thomas</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Ant]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.onelittlerobot.co.uk/?p=475</guid>
		<description><![CDATA[No one likes repetitive work, it&#8217;s not only boring but is a good way to introduce errors into your code. The best way to eliminate bugs from your code is to not write any code When I first started using frameworks, PureMVC and Caingorm my working processes was to spend a chunk of time setting [...]]]></description>
			<content:encoded><![CDATA[<p>No one likes repetitive work, it&#8217;s not only boring but is a good way to introduce errors into your code. The best way to eliminate bugs from your code is to not write any code <img src='http://www.onelittlerobot.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>When I first started using frameworks, PureMVC and Caingorm my working processes was to spend a chunk of time setting up the environment, creating the basic framework files, often these were copied from a previous project and renamed, I toyed with the idea of creating a startup project but this also involved copying and renaming files to get started, not an ideal situation.</p>
<p>Over time I found several projects that would create all the startup files you need to use one of these frameworks but they never seemed quite right for me.</p>
<p>This is where ANT comes in, not only is it a great tool for deploying projects but after installing it in Flash Builder (it comes pre installed if you&#8217;ve installed Flash Builder on top of Eclipse) you have pretty much all the tools you need to build your own tool to quickly start a project.</p>
<p><span id="more-475"></span></p>
<p>That&#8217;s the point of this post so here&#8217;s how I created mine, it&#8217;s tailored to my working practices and I can quickly amend it or explain it to the others on my team. I&#8217;ve recently created a tool to build robot legs projects, unfortunately as I did it for my current employer I&#8217;m not really allowed to share it so this won&#8217;t target a specific framework but should give you the basics to create your own.</p>
<p>If you&#8217;ve got ant installed you&#8217;re good to go, if not have a look <a href="http://www.zoltanb.co.uk/articles/flash-blog/162-fb4-standalone-how-to-install-ant-in-flash-builder-4-premium">here</a>.</p>
<p><img class="alignleft size-full wp-image-517" title="Folder Structure" src="http://www.onelittlerobot.co.uk/wp-content/uploads/2010/08/files2.png" alt="" width="196" height="179" />First things first create a new Flex project, in the root of that project create a folder called builderTool, this is where we&#8217;ll be working. While your at it create a folder in there called templates.</p>
<p>The “templates” folder will contain template files, which will be .as or .mxml files with placeholder tags.</p>
<p>Now we need to create two text files in your builderTool folder, one called build.properties this file will be where we will store properties specific to the tool the other called build.xml this will contain the commands used in the tool.</p>
<h2>The Properties File</h2>
<p>Open up the  build.properties file, we need to define some basic properties for the tool:</p>
<ul>
<li>base folder location, this is the root of your flex project</li>
<li>source folder location, the source folder in your flex project</li>
<li>the template folder location, the template folder we created earlier</li>
</ul>
<p>as well as this we need some project specific properties, these are the ones you&#8217;ll need to change each time you start up a new project. These are:</p>
<ul>
<li>project name</li>
<li>project path</li>
<li>project namespace</li>
<li>your name</li>
<li>your company</li>
<li>your email</li>
<li>the year</li>
</ul>
<p>and lastly the folder names for the framework your using</p>
<ul>
<li>Default folders for model, view and controller files</li>
</ul>
<p>these are just name value pairs in a text file, you can copy the ones below and edit them</p>
<pre class="brush: plain;">
#####################################################################
#
#  CORE Properties
#
#####################################################################

BASE_DIR						=../
SRC_DIR							=${BASE_DIR}src/
TEMPLATES_DIR				=templates

#####################################################################
#
#  PROJECT Properties
#
#####################################################################

# package such as: com.siteName.project
PROJECT_PACKAGE			= com.site.project
# project path such as: com/siteName/project
PROJECT_PATH				= ${SRC_DIR}com/siteName/project/

AUTHOR_NAME					=Your Name
AUTHOR_EMAIL				=your@email.com
COMPANY_NAME				=Your Company Name
PROJECT_NAME				=The Name of the project
YEAR								=2010

#####################################################################
#
#  FRAMEWORK DIRECTORIES
#
#####################################################################

CONTROL_DIR				= ${PROJECT_PATH}control/
CONTROL_PACKAGE		= ${PROJECT_PACKAGE}.control
MODEL_DIR					= ${PROJECT_PATH}model/
MODEL_PACKAGE			= ${PROJECT_PACKAGE}.model
VIEW_DIR					= ${PROJECT_PATH}view/
VIEW_PACKAGE			= ${PROJECT_PACKAGE}.view
</pre>
<p><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } -->you&#8217;ll notice that some of the properties in the file require previous properties before they can be defined, also that in order to reference a defined property you need to put it between ${}.</p>
<p>With that done we can get on with creating some commands for the tool.</p>
<h2>The Build File</h2>
<p>Open up the build.xml file, we need to create a project which will be the root node of the file and import the properties we created in the last step.</p>
<p>Now is as good a time as any to open the ant view.</p>
<p>Select Window, Other views&#8230;</p>
<p style="text-align: center;"><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } --><img class="size-full wp-image-525 aligncenter" title="Window Dropdown" src="http://www.onelittlerobot.co.uk/wp-content/uploads/2010/08/menu.png" alt="" width="278" height="144" /></p>
<p>In the views popup window, open the ant folder and select ant.</p>
<p><img class="aligncenter size-full wp-image-532" title="Other Views Popup" src="http://www.onelittlerobot.co.uk/wp-content/uploads/2010/08/popup.png" alt="" width="299" height="403" /></p>
<p>we&#8217;ll add some functions to the build file but first drag it from the package explorer to the ant view.</p>
<p>You should see something like this</p>
<p><img class="aligncenter size-full wp-image-528" title="The Ant View" src="http://www.onelittlerobot.co.uk/wp-content/uploads/2010/08/antview.png" alt="" width="420" height="177" /></p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;project name=&quot;Demo Ant Project&quot;&gt;
	&lt;property file=&quot;build.properties&quot; /&gt;
&lt;/project&gt;
</pre>
<h3>First Function</h3>
<p>A good first function to create would be to create all the default folders for your framework.</p>
<p style="padding-left: 30px;">Before we do that a brief explanation of how ant works is in order. Ant uses a node called target to contain a series of tasks. These tasks are each defined by a node with various attributes and child nodes.<br />
We&#8217;ll create a target called create folders which will create the framework folders defined in the properties file.</p>
<pre class="brush: xml;">
&lt;target name=&quot;Create Folders&quot;&gt;
	&lt;echo&gt;Start Making Folders&lt;/echo&gt;
	&lt;mkdir dir=&quot;${CONTROL_DIR}&quot; /&gt;
	&lt;mkdir dir=&quot;${MODEL_DIR}&quot; /&gt;
	&lt;mkdir dir=&quot;${VIEW_DIR}&quot; /&gt;
	&lt;echo&gt;Done Making Folders&lt;/echo&gt;
&lt;/target&gt;
</pre>
<p>The name attribute is the title of the function which will show in the ant view<br />
We&#8217;ve used two types of tags used in this function:</p>
<ul>
<li>echo, which displays some feedback in the console view</li>
<li>mkdir which you&#8217;ll recognise if ever used a terminal interface or various other programming languages <a href="http://en.wikipedia.org/wiki/Mkdir">http://en.wikipedia.org/wiki/Mkdir</a>, it creates the directory specified by it&#8217;s dir attribute.</li>
</ul>
<p>After adding this to your build file and saving you should notice a function appear in your ant view, double click on that and ant will create those folders in your source folder, you may need to refresh that folder to see them.</p>
<h3>More Complication</h3>
<p>Thats a good start but now we need to create some files to go in the folders, I&#8217;m going to create a basic model file and populate it with the properties from the properties file we created.</p>
<p>To do this we will need to create a template as file, what you&#8217;ll learn here can also be used to create mxml files for views or pretty much any other type of text file you could want.</p>
<p>Create a new file in the templates folder and name it model.as. Open the file and add the following text</p>
<pre class="brush: as3;">

package @package@
{
	import your.framework.AbstractModel;

	/**
	 *
	 * &lt;p&gt;What does @class.name@ do?&lt;/p&gt;
	 *
	 * Copyright (c) @year@ @company.name@, All Rights Reserved
	 * @author   @author.name@
	 * @contact  @author.email@
	 * @project  @project.name@
	 *
	 */
	public class @class.name@ extends AbstractModel
	{
		public function @class.name@()
			{
				super();
				trace(&quot;I am a new @class.name@&quot;);
			}
	}
}
</pre>
<p>This is a non specific model file, doesn&#8217;t do anything but you should be able to see how it could be filled with all sorts of fancy framework specific stuff.</p>
<p>Notice the tags between @ symbols, those will be replaced when we copy this file using a command, lets get on and write that command now.</p>
<pre class="brush: xml;">
&lt;target name=&quot;Create a model&quot;&gt;
	&lt;description&gt;This Creates a new Model&lt;/description&gt;
	&lt;input message=&quot;Enter model Name:&quot; addproperty=&quot;gesture&quot; /&gt;
	&lt;copy file=&quot;${TEMPLATES_DIR}/Model.as&quot; tofile=&quot;${MODEL_DIR}${gesture}Model.as&quot;&gt;
		&lt;filterchain&gt;
			&lt;replacetokens&gt;
				&lt;token key=&quot;author.name&quot; value=&quot;${AUTHOR_NAME}&quot; /&gt;
				&lt;token key=&quot;author.email&quot; value=&quot;${AUTHOR_EMAIL}&quot; /&gt;
				&lt;token key=&quot;company.name&quot; value=&quot;${COMPANY_NAME}&quot; /&gt;
				&lt;token key=&quot;project.name&quot; value=&quot;${PROJECT_NAME}&quot; /&gt;
				&lt;token key=&quot;package&quot; value=&quot;${MODEL_PACKAGE}&quot; /&gt;
				&lt;token key=&quot;year&quot; value=&quot;${YEAR}&quot; /&gt;
				&lt;token key=&quot;class.name&quot; value=&quot;${gesture}Model&quot; /&gt;
			&lt;/replacetokens&gt;
		&lt;/filterchain&gt;
	&lt;/copy&gt;
	&lt;echo&gt;${MODEL_DIR}${gesture}Model.as created&lt;/echo&gt;
&lt;/target&gt;
</pre>
<p>This one&#8217;s a little more complicated, what we are doing is asking what would you like your model to be called, we do this by using a input tag, this defines a property called gesture which we use to name the file copied to the model folder.</p>
<p>The filterchain defines filters that will be used on the file we want to replace some text in side the file so we use replacetokens and define those tokens using a series of key/value pairs.</p>
<p>If you double click on that command in your ant view you should see get a popup window, type the name of your Model Class in there ant it will be created in you model folder.</p>
<p>I hope that all made sense, there&#8217;s more you can do with this but for now I&#8217;ll stick a copy of the project we&#8217;ve been working on here <a href="http://www.onelittlerobot.co.uk/wp-content/uploads/2010/08/AntDemo1.zip"></a><a href="http://www.onelittlerobot.co.uk/wp-content/uploads/2010/08/AntDemo1.zip">Ant demo files</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.onelittlerobot.co.uk/2010/08/07/actionscript-ant-tool-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3D Menu Redux</title>
		<link>http://www.onelittlerobot.co.uk/2009/10/12/3d-menu-redux/</link>
		<comments>http://www.onelittlerobot.co.uk/2009/10/12/3d-menu-redux/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 19:35:00 +0000</pubDate>
		<dc:creator>Kevin Thomas</dc:creator>
				<category><![CDATA[Demos]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[papervision]]></category>

		<guid isPermaLink="false">http://www.onelittlerobot.co.uk/?p=139</guid>
		<description><![CDATA[Playing around with a 3D model we had at work in Flex. Getting the nodes from the collada file and creating some interactions. Takes a little time to load the model and related assets. Click on the buildings to interact with the map. Demo]]></description>
			<content:encoded><![CDATA[<p>Playing around with a 3D model we had at work in Flex. Getting the nodes from the collada file and creating some interactions. Takes a little time to load the model and related assets. Click on the buildings to interact with the map.</p>
<p><a rel="shadowbox;height=480;width=880" href="http://www.onelittlerobot.co.uk/examples/3d/menuRedux/Main.html">Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onelittlerobot.co.uk/2009/10/12/3d-menu-redux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sudoku</title>
		<link>http://www.onelittlerobot.co.uk/2009/09/27/sudoku/</link>
		<comments>http://www.onelittlerobot.co.uk/2009/09/27/sudoku/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 19:42:58 +0000</pubDate>
		<dc:creator>Kevin Thomas</dc:creator>
				<category><![CDATA[Sudoku]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://www.onelittlerobot.co.uk/?p=111</guid>
		<description><![CDATA[Another go at a sudoku game, built in flex with a codeignitor backend. Seems to be throwing up the occasional error at the moment just dismiss all and it should be fine. Been thinking about this for ages so will hopefully get some time to work on finishing this soonish. Uses CodeIgniter and JSON for [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="shadowbox;height=580;width=600" href="http://www.onelittlerobot.co.uk/sudoku/demo/Main.swf"><img class="alignleft size-thumbnail wp-image-124" title="sudoku" src="http://www.onelittlerobot.co.uk/wp-content/uploads//sudoku-150x150.png" alt="sudoku" width="150" height="150" /></a>Another go at a sudoku game, built in flex with a codeignitor backend. Seems to be throwing up the occasional error at the moment <img src='http://www.onelittlerobot.co.uk/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  just dismiss all and it should be fine.</p>
<p>Been thinking about this for ages so will hopefully get some time to work on finishing this soonish.</p>
<p>Uses <span>CodeIgniter and JSON for managing the server interaction.<br />
</span></p>
<p><a rel="shadowbox;height=580;width=600" href="http://www.onelittlerobot.co.uk/sudoku/demo/Main.swf">Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onelittlerobot.co.uk/2009/09/27/sudoku/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

