<?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>markstar &#187; Actionscript</title>
	<atom:link href="http://markstar.co.uk/blog/category/flashplatform/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://markstar.co.uk/blog</link>
	<description>blogging about the flash platform</description>
	<lastBuildDate>Sat, 31 Jul 2010 09:16:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>StarDribbbleLib – AS3 Dribbble Library</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/actionscript/stardribbblelib-%e2%80%93-as3-dribbble-library/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/actionscript/stardribbblelib-%e2%80%93-as3-dribbble-library/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 09:16:18 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[StarDribbbleLib]]></category>
		<category><![CDATA[StarRequests]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[AS3-Signals]]></category>
		<category><![CDATA[Dribbble]]></category>
		<category><![CDATA[Library]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=333</guid>
		<description><![CDATA[The Dribbble API has been developed recently to allow developers access to the shots people share. StarDribbbleLib has been developed in AS3 to allow developers access to the Dribbble API.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a title="StarDribbbleLib" href="http://bit.ly/stardribbblelib" target="_blank"><img class="size-full wp-image-340 aligncenter" title="StarDribbleLib" src="http://markstar.co.uk/blog/wp-content/uploads/2010/07/StarDribbleLib.png" alt="StarDribbbleLib" width="592" height="380" /></a></p>
<h3>What is Dribbble?</h3>
<p><a title="Dribbble" href="http://dribbble.com/" target="_blank">Dribbble</a> is show and tell for designers, developers and other creatives. Share sneak peeks of your work as “shots” &#8211; small screenshots of the designs and applications you’re working on.<br />
<span id="more-333"></span></p>
<h3>The Dribbble API</h3>
<p>The <a title="Dribbble API" href="http://dribbble.com/api" target="_blank">Dribbble API</a> has been developed recently to allow developers access to the “shots” that people share. There are a small amount of methods available at the moment, with plans in the future for more advanced API methods such as login and publishing a “shot”.</p>
<h3>StarDribbbleLib</h3>
<p><a title="StarDribbbleLib" href="http://github.com/markstar/StarDribbbleLib/" target="_blank">StarDribbbleLib</a> is an AS3 library, which was built using <a title="StarRequests" href="http://github.com/markstar/StarRequests" target="_blank">StarRequests</a>, that allows developers to connect to the Dribbble API. If you’ve used <a title="StarRequests" href="http://github.com/markstar/StarRequests" target="_blank">StarRequests</a> (or <a title="StarImageLib" href="http://github.com/markstar/StarImageLib" target="_blank">StarImageLib</a>) before then you’ll already know how to use <a title="StarDribbbleLib" href="http://github.com/markstar/StarDribbbleLib/" target="_blank">StarDribbbleLib</a>. Each of the methods of the Dribbble API have been made available as modular requests.</p>
<h3>Modular Requests</h3>
<p>Each request in the library implements the same interface, which is displayed below.</p>
<p><script src="http://gist.github.com/501955.js"> </script></p>
<p>The started, progress and failed signals always dispatch the same payload. The started signal doesn&#8217;t dispatch a payload, the progress signal dispatches a Number (percentage) and the failed signal dispatches a String (the reason why it failed).</p>
<p>The only signal that changes its payload is the completed signal; this changes depending on the type of request you are making. For example, if you&#8217;re requesting shots (PopularShotsRequest) then the payload is of Shots type, whereas if you&#8217;re requesting a player (PlayerByIDRequest) then the payload is of Player type, likewise a shot request (ShotByIDRequest) will have a payload of type Shot.</p>
<h3>Available API Methods</h3>
<ul>
<li>DebutShotsRequest( page, amountPerPage )</li>
<li>EveryoneShotsRequest( page, amountPerPage )</li>
<li>FollowingShotsByPlayerIDRequest( playerID, page, amountPerPage )</li>
<li>FollowingShotsByPlayerUsernameRequest( playerUsername, page, amountPerPage )</li>
<li>PlayerByIDRequest( playerID )</li>
<li>PlayerByUsernameRequest( playerUsername )</li>
<li>PlayerShotsByIDRequest( playerID, page, amountPerPage )</li>
<li>PlayerShotsByUsernameRequest( playerUsername, page, amountPerPage )</li>
<li>PopularShotsRequest( page, amountPerPage )</li>
<li>ShotByIDRequest( shotID )</li>
</ul>
<h3>Code examples</h3>
<p>Simply download the SWC from the <a title="StarDribbbleLib downloads page" href="http://github.com/markstar/StarDribbbleLib/downloads" target="_blank">downloads page</a> and use it in your project.<br />
<script src="http://gist.github.com/501408.js"></script><br />
<script src="http://gist.github.com/501415.js"></script><br />
<script src="http://gist.github.com/501409.js"></script></p>
<h3>GitHub</h3>
<p>The <a title="StarDribbbleLib" href="http://github.com/markstar/StarDribbbleLib/" target="_blank">StarDribbbleLib</a> is available on GitHub. Don’t forget you can fork the project and add issues.</p>
<h3>Disclaimer</h3>
<p>The <a title="Dribbble API" href="http://dribbble.com/api" target="_blank">Dribbble API</a> is in its first draft and therefore isn’t completely defined. This library works with the API in its current form and is no way affiliated with Dribbble. I have been providing feedback to the API developers to help improve the service and will continue to keep this library up to date. The information displayed above is correct at the time of writing.</p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/actionscript/stardribbblelib-%e2%80%93-as3-dribbble-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>StarRequests: Making modular requests using AS3 Signals</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/actionscript/starrequests-making-modular-requests-using-as3-signals/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/actionscript/starrequests-making-modular-requests-using-as3-signals/#comments</comments>
		<pubDate>Mon, 17 May 2010 11:00:30 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[StarRequests]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[AS3-Signals]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[Library]]></category>
		<category><![CDATA[Modular]]></category>
		<category><![CDATA[Queue]]></category>
		<category><![CDATA[Robotlegs]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=317</guid>
		<description><![CDATA[Background
The concept of making modular requests is one I&#8217;ve used in recent projects, and I thought it was time to standardise and release this as a library. Each request revolves around a simple interface:

The aim is to make each request modular, consistent, simple and for it to clean up after itself. By making each request [...]]]></description>
			<content:encoded><![CDATA[<h3>Background</h3>
<p>The concept of making modular requests is one I&#8217;ve used in recent projects, and I thought it was time to standardise and release this as a library. Each request revolves around a simple interface:</p>
<p><script src="http://gist.github.com/397802.js"></script></p>
<p>The aim is to make each request modular, consistent, simple and for it to clean up after itself. By making each request implement an interface, and therefore consistent, it facilitates the creation of useful utilities. With this in mind I thought I&#8217;d put together a library of common requests and utilities.<br />
<span id="more-317"></span></p>
<h3>Benefits of using AS3 Signals</h3>
<p>The main benefits of using <a title="AS3 Signals at GitHub" href="http://github.com/robertpenner/as3-signals" target="_blank">AS3 signals</a> over the traditional AS3 event system (for me) are that signals can be defined in an interface and a signal can free itself up for garbage collection by removing all of its listeners.</p>
<p>By defining the signals in an interface we can be certain that any implementation of the interface implements the defined signals; in this case each request much have an implementation of the started, progress, completed and failed signals. The advantage of this is that any utility class we create knows the signals that each request can dispatch, because they are enforced by the interface.</p>
<p>Another advantage of using <a title="AS3 Signals at GitHub" href="http://github.com/robertpenner/as3-signals" target="_blank">AS3 signals</a> in this library is the ability to remove all of the listeners of a particular signal at once, which is another feature not available to us when using the traditional event model. The benefit of using this method is that once a request has dispatch its failed or completed signal it can then confidently free itself up for garbage collection without worrying if all listeners have been removed (we all know that not removing event listeners is a common cause of memory leaks!).</p>
<p>As a side note, without the <a title="AS3 Signals at GitHub" href="http://github.com/robertpenner/as3-signals" target="_blank">AS3 signals</a> library I wouldn&#8217;t have thought of requests in terms of interfaces and thus created this library!</p>
<h3>StarRequests</h3>
<p>The initial release of StarRequests includes some common load requests, a batch utility and a queue utility. For now, I&#8217;ve only included the common requests that I&#8217;ve used in recent projects, which include loading an XML file, a Bitmap and BitmapData. I plan to add more varied requests as times go on as there&#8217;s no restriction on the types of requests that can be implemented. Heck, you could have a move request that moves a Sprite to a specified position. The point is that as long as a request implements the correct interface it doesn&#8217;t matter what the request does. Other ideas for requests include File I/O requests, database requests, etc.</p>
<p>The library includes a queue utility, which allows you to continuously add requests to the queue utility and it will execute them in the order they are added.  This utility could prove particularly useful when creating applications that are continuously updated via external APIs, such as a Twitter client.</p>
<p>The other utility that&#8217;s included initially is a batch utility that allows you to set up a batch of requests to be sent together, one after the other. The clever thing about this utility is that it also implements the request interface, so you can create a batch of requests that can then be included in another batch or added to a queue. Without defined interfaces, and the use of <a title="AS3 Signals at GitHub" href="http://github.com/robertpenner/as3-signals" target="_blank">AS3 signals</a>, implementing this functionality using the traditional event model would have been a lot more complex!</p>
<h3>Timesaver</h3>
<p>Not only are the requests included in StarRequests modular and consistent they also help you save time when coding. The idea being that not only do StarRequests promote a good use of polymorphism, but they also require less lines of code to use. The following snippet shows loading an XML file using normal loading techniques, and cleaning that request once it&#8217;s complete.</p>
<p><script src="http://gist.github.com/402384.js"></script></p>
<p>And now look at the same functionality using StarRequests.</p>
<p><script src="http://gist.github.com/402387.js"></script></p>
<p>It&#8217;s much quicker to write the code to load XML files using StarRequests, and it takes out the complexities of cleaning up for you! Now imagine trying to create a queue for loading XML files in the normal way, or a batch process, it would be complicated but StarRequests makes that really easy for you.</p>
<p><script src="http://gist.github.com/402388.js"></script></p>
<h3>Using StarRequests with Robotlegs</h3>
<p>I&#8217;m almost exclusively using <a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> with <a title="AS3 Signals at GitHub" href="http://github.com/robertpenner/as3-signals" target="_blank">AS3 signals</a> for all Flash Platform projects and so I wanted to make sure that StarRequests fits in with my current workflow. I think it does. Each request is completely modular, fitting in with Robotlegs&#8217; philosophy, and therefore can easily incorporated into a Robotlegs project. It&#8217;s even possible to set up a centralised request queue service for your application so every service sends their requests to the centralised queue to be sent.</p>
<h3>Using StarRequests to build API libraries</h3>
<h3><span style="font-weight: normal; font-size: 13px;">Using StarRequests to build API libraries could prove to be very powerful. Imagine a Twittier API library built using StarRequests; you could have a <em>login request</em>, <em>update status request</em>, <em>get friends request</em> and a <em>get timeline request</em> all of which could return strongly typed responses in their completed signals, and could be added to queues. This would be much more efficient than expecting the user to manual parse each response. Furthermore, if you look at the code examples above you&#8217;ll see how easy the API for the library could be!</span></h3>
<h3><span style="font-weight: normal; font-size: 13px;">Another advantage to using StarRequests is that, because each request is modular, the compiler only needs to include the requests that are used as opposed to the entire library (usually an API library is encompassed in one class). Separating the requests into their own classes can help to reduce the final file size of the compiled application.</span></h3>
<h3>Download StarRequests</h3>
<p>The StarRequests library is available to download from GitHub as both <a title="StarRequests source code" href="http://github.com/markstar/StarRequests/tree/master/StarRequests/src/" target="_blank">the source code</a> and <a title="StarRequests Downloads" href="http://github.com/markstar/StarRequests/downloads" target="_blank">a SWC file</a>. It can be used in any AS3 project whether it uses the Flex framework or not; so you have no excuse not to try it out!</p>
<h3>Feedback</h3>
<p>Please feedback on any issues or requests you have using the <a title="Issue tracking at GitHub for StarRequests" href="http://github.com/markstar/StarRequests/issues" target="_blank">issue tracking at GitHub</a> and I will endeavour to solve the issue or implement your request (if I feel it fits in with the library).</p>
<h3>Todo list</h3>
<ul>
<li><del datetime="2010-05-15T22:33:54+00:00">Add ASDoc comments to the library</del> Update: The library now has ASDocs!</li>
<li>Implement unit testing</li>
<li>Add more common requests/utilities</li>
<li>(Possibly) create API libraries for common services (Twitter, Flickr, etc) using StarRequests</li>
</ul>
<h3>Disclaimer</h3>
<p>This is the first release of StarRequests and thus as improvements and additions are made the structure of the library may change slightly.</p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/actionscript/starrequests-making-modular-requests-using-as3-signals/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Getting Started with Robotlegs</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/actionscript/getting-started-with-robotlegs/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/actionscript/getting-started-with-robotlegs/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 11:43:15 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Robotlegs]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[micro-architecture]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=247</guid>
		<description><![CDATA[Robotlegs has been gaining a lot of ground over the last few months within the Flash community, and so I thought it was about time I gave it a shot. This post contains links to some useful resources to help you get started with Robotlegs.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.robotlegs.org/"><img class="size-full wp-image-251 alignleft" title="Robotlegs logo" src="http://markstar.co.uk/blog/wp-content/uploads/2010/03/RobotLegs1.jpg" alt="Robotlegs logo" width="150" height="130" /></a></p>
<p><a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> has been gaining a lot of ground over the last few months within the Flash community, and so I thought it was about time I gave it a shot. This post includes some of the resources I found really useful when getting started with the framework.<br />
<span id="more-247"></span></p>
<h3>What is Robotlegs?</h3>
<p>If you haven&#8217;t heard of <a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> before there&#8217;s a good explanation on their <a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">website</a>:</p>
<blockquote><p><strong>Robotlegs</strong> is a <strong>pure AS3</strong> micro-architecture (framework) with a light footprint and limited scope. Simply put, Robotlegs is there to help you wire your objects together. It provides the <strong>glue</strong> that your application needs to easily function in a decoupled way. Through the use of automated metadata based dependency injection Robotlegs <strong>removes boilerplate</strong> code in an application. By promoting loose coupling and avoiding the use of Singletons and statics in the framework Robotlegs can help you write code that is highly <strong>testable</strong>.</p></blockquote>
<p><a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> was heavily influenced by <a title="PureMVC website" href="http://puremvc.org/" target="_blank">PureMVC</a>, another pure AS3 micro-architecture framework, therefore if you are familiar with the roles and architecture PureMVC has then you will find Robotlegs easy to pick up. You will also notice that there&#8217;s a helluva lot less boiler-plate code in Robotlegs!</p>
<h3>Where should I start?</h3>
<p>A lot of people recommend getting started with the Robotlegs best practices document and whilst this is a good place to start it can be really overwhelming, even for someone familiar with frameworks, so I&#8217;d recommend watching the following video tutorials first.</p>
<ul>
<li><a title="http://pv3d.org/2009/11/18/robotlegs-hello-world-video-tutorial/" href="http://pv3d.org/2009/11/18/robotlegs-hello-world-video-tutorial/" target="_blank">RobotLegs Hello World Video Tutorial</a> by <a title="John Lindquist on Twitter" href="http://twitter.com/johnlindquist" target="_blank">John Lindquist</a></li>
<li><a title="Robotlegs MVCS: Walkthrough of an AIR Twitter Client" href="http://joelhooks.com/2009/11/11/a-walkthrough-of-an-air-twitter-client-using-robotlegs-mvcs/" target="_blank">Robotlegs MVCS: Walkthrough of an AIR Twitter Client</a> by <a title="Joel Hooks on Twitter" href="http://twitter.com/jhooks" target="_blank">Joel Hooks</a></li>
</ul>
<p>Once you watched the videos you&#8217;ll have an rough understanding of each of the roles within Robotlegs; this is a great time to check out the <a title="Robotlegs Best Practices" href="http://wiki.github.com/robotlegs/robotlegs-framework/best-practices" target="_blank">best practices document</a> and build on that knowledge. If you then watch the video tutorials again you should really understand exactly what&#8217;s going on!</p>
<h3>What&#8217;s next?</h3>
<p>Start using it! You can download the latest release version from the <a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">Robotlegs website</a> or, if you&#8217;re familiar with GitHub, you can <a title="Robotlegs on GitHub" href="http://github.com/robotlegs/robotlegs-framework" target="_blank">fork the repository</a>. There&#8217;s some really useful <a title="Robotlegs Demos on GitHub" href="http://github.com/robotlegs/robotlegs-demos-Bundle" target="_blank">demos available on GitHub</a> too, which include examples of using the framework with Flash, modular development and the integration of services such as Flickr and GoogleMaps.</p>
<p>Don&#8217;t forget, if you&#8217;re really stuck you can always <a title="Robotlegs knowledge base" href="http://knowledge.robotlegs.org/" target="_blank">ask for help</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/actionscript/getting-started-with-robotlegs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HYPE ShapeLayout Experiment</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/actionscript/hype-shapelayout-experiment/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/actionscript/hype-shapelayout-experiment/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 22:59:13 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Experiment]]></category>
		<category><![CDATA[HYPE]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=236</guid>
		<description><![CDATA[I couldn't resist sharing one of my recent experiments with the HYPE framework. It also uses the MinimalComps component set. The example makes use of the ObjectPool, ColorPool and ShapeLayout classes.]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t resist sharing one of my recent experiments with the <a title="HYPE Framework" href="http://hype.joshuadavis.com/" target="_blank">HYPE framework</a> (it also uses the <a title="MinimalComps" href="http://www.bit-101.com/minimalcomps/" target="_blank">MinimalComps</a> component set). The example makes use of the ObjectPool, ColorPool and ShapeLayout classes. It&#8217;s really cool that you can put stuff like this together in just a few hours. I will be adding the source to GitHub soon, which should hopefully make it more interesting!</p>
<p>Update: The source code is <a title="ShapeLayout Experiment source code" href="http://github.com/markstar/hype/tree/master/examples/markstar/HypeShapeLayoutTest/" target="_blank">now available</a>.<br />
<span id="more-236"></span></p>
<p style="text-align: center;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_HypeShapeLayoutTest_1643439904"
			class="flashmovie"
			width="592"
			height="270">
	<param name="movie" value="http://markstar.co.uk/flash/hype/HypeShapeLayoutTest.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://markstar.co.uk/flash/hype/HypeShapeLayoutTest.swf"
			name="fm_HypeShapeLayoutTest_1643439904"
			width="592"
			height="270">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/actionscript/hype-shapelayout-experiment/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>FileReference woes on MACs</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/actionscript/filereference-woes-on-macs/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/actionscript/filereference-woes-on-macs/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 22:37:02 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[2038]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[FileReference]]></category>
		<category><![CDATA[MAC]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=221</guid>
		<description><![CDATA[Today I found out (the hard way) that there are several issues that can occur when trying to upload files using the FileReference class on MACs. This post identifies those issues and their solutions.]]></description>
			<content:encoded><![CDATA[<p>Today I found out (the hard way) that there are several issues that can occur when trying to upload files using the FileReference class on MACs.</p>
<h3>FileReference.type always returns null</h3>
<p>It&#8217;s often that case that you want to restrict the file type the user can upload, or perform different processes depending on the type of file uploaded. However the type property of a FileReference object always returns null on MACs; to work around this you must get the file extension manually. To do this you can use the following code (it&#8217;s good practice to always convert the file extension to lower case before working with it).<br />
<span id="more-221"></span><script src="http://gist.github.com/308111.js"></script></p>
<h3>Server script must return data</h3>
<p>When uploading files using the FileReference class you may experience the upload getting stuck at 100% progress and never firing the Event.COMPLETE event. This will only happen on the MAC and it&#8217;s because Flash doesn&#8217;t realise that the file has finished uploading until it gets a response from the server. I don&#8217;t why this is implemented differently on the different operating systems, but to overcome this problem your server script must write something to the page (it can just be a space character!).</p>
<h3>Parameters must be added using URLVariables</h3>
<p>You may want to pass URL parameters to the server script when uploading a file, and in our case the parameters and the URL were passed as one string via Flash vars. MACs don&#8217;t like this. So instead we have to pass the parameters using the data property of the URLRequest; to do this you need to use the URLVariables class. The following code snippet shows you how.<br />
<script src="http://gist.github.com/309031.js"></script></p>
<h3>Feedback!</h3>
<p>Has anyone else come across any weird quirks or handy hints when working with the FileReference class? Please leave a comment if you have and I&#8217;ll add it to the post!</p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/actionscript/filereference-woes-on-macs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clipboard Management using the StatefulToolkit</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/actionscript/clipboard-management-using-the-statefultoolkit/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/actionscript/clipboard-management-using-the-statefultoolkit/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 09:00:10 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[StatefulToolkit]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=196</guid>
		<description><![CDATA[This tutorial will build upon the Introduction to using the StatefulToolkit example; it will add the ability to utilize the Clipboard in our example. The example will use the ClipboardUtil, which is a utility class included in the toolkit that allows the user to copy and paste objects using the clipboard. The example application will build upon the last one; it will allow the user to position four circles, to save and load the state of the circles (i.e. where the circles are positioned) and to copy and paste the circles.]]></description>
			<content:encoded><![CDATA[<h3>Tutorial Overview</h3>
<p>This tutorial will build upon the <a title="Introduction to using the StatefulToolkit" href="http://markstar.co.uk/blog/2010/statefultoolkit/introduction-to-using-statefultoolkit/" target="_blank">Introduction to using the StatefulToolkit</a> example; it will add the ability to utilize the Clipboard in our example. The example will use the ClipboardUtil, which is a utility class included in the toolkit that allows the user to copy and paste objects using the clipboard. The example application will build upon the last one; it will allow the user to position four circles, to save and load the state of the circles (i.e. where the circles are positioned) and to copy and paste the circles. The example can be <a title="View the compiled application" href="#compiledapplication">seen here</a> and <a title="Application Source Code" href="#sourcecode">source files are available</a>.</p>
<h3>Preparation</h3>
<p>Before you being implementing this tutorial make sure you have the latest version of the <a title="StatefulToolkit Downloads at GitHub" href="http://github.com/markstar/StatefulToolkit/downloads" target="_blank">StatefulToolkit SWC</a>, and that you’re project is set to target Flash Player 10 (if you want to target FP9, simple replace the Vector with an array in the circle container) . This tutorial also uses Keith Peter’s <a title="Minimal Comps at BIT-101" href="http://www.bit-101.com/minimalcomps/" target="_blank">Minimal Comps</a> component set to create the buttons in the application so you may want to grab the SWC for that too, but you can use your own buttons if you prefer. Both SWC files are included in the <a title="Application Source Code" href="#sourcecode">available flex project</a>.<br />
<span id="more-196"></span></p>
<h3>Creating the Statable Object</h3>
<p>The original circle class could be left as it is, however it would be helpful to know which circle we have selected, so we know which one we are adding to the clipboard. In order to do show this we will add two new methods to the Circle; select and deselect. Each method draws the circle in a different colour. The full contents of this class can be seen below.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> couk.markstar.examples.ui
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> couk.markstar.statefultoolkit.core.IStatable;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Circle extends <span style="color: #004993;">Sprite</span> implements IStatable
	<span style="color: #000000;">&#123;</span>
		<span style="color: #3f5fbf;">/**
		 * The constructor draws the circle with a grey outline
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Circle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span> 0x999999 <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Change the display of the circle to show it's selected
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">select</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span> 0x990000 <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Change the display of the circle to the default
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> deselect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span> 0x999999 <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Retrieve the state of the circle storing the x and y properties
		 *
		 * @return The current state of the circle as an XML string
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> retrieveState<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> xml<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">'&lt;object&gt;'</span>;
			xml <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'&lt;x&gt;'</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">'&lt;/x&gt;'</span>;
			xml <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'&lt;y&gt;'</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">'&lt;/y&gt;'</span>;
			xml <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'&lt;/object&gt;'</span>;
			<span style="color: #0033ff; font-weight: bold;">return</span> xml;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Set the state of the circle by getting it's x and y values from the xml
		 *
		 * @param state The new state of the circle
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> setState<span style="color: #000000;">&#40;</span> state<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">x</span> = <span style="color: #004993;">Number</span><span style="color: #000000;">&#40;</span> state.<span style="color: #004993;">x</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">y</span> = <span style="color: #004993;">Number</span><span style="color: #000000;">&#40;</span> state.<span style="color: #004993;">y</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Used internally for creating the circles' graphics
		 * 
		 * @param lineColor The color of the line around the circle
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span> lineColor<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">graphics</span>.<span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">graphics</span>.<span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">1</span>, lineColor <span style="color: #000000;">&#41;</span>
			<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span> 0xFFFFFFF <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">10</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>Creating the Container</h3>
<p>Previously the circle container implemented the IStatable interface but it now implements the IStateContainer interface, because it needs to interact with the ClipboardUtil. The IStateContainer interface inherits functionality from the IStatable interface, so the circle container is still required to have the methods setState and retrieveState, but it is also required to have the methods addObjectByState, hasSelectedObject and retrieveSelectedObject.</p>
<p>The addObjectByState method was already implemented in the previous function, but was used internally, now it will be used by the ClipboardUtil when the user is pasting an object. In order to implement hasSelectedObject and retrieveSelectedObject we must add to the circleDownListener. After setting the _currentCircle we can call the select method of the circle to show that it has been selected. Then, before we set the _currentCircle to the one the user has mouse downed, we must deselect the old one by calling it&#8217;s deselect method. The full contents of this class can be seen below.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> couk.markstar.examples.ui
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> couk.markstar.statefultoolkit.core.IStatable;
	<span style="color: #0033ff; font-weight: bold;">import</span> couk.markstar.statefultoolkit.core.IStateContainer;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span>.<span style="color: #004993;">Point</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CircleContainer extends <span style="color: #004993;">Sprite</span> implements IStateContainer
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _circles<span style="color: #000000; font-weight: bold;">:</span>Vector.<span style="color: #000000; font-weight: bold;">&lt;</span>Circle<span style="color: #000000; font-weight: bold;">&gt;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _currentCircle<span style="color: #000000; font-weight: bold;">:</span>Circle;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _dragOffset<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Point</span>;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * The constructor the vector containing the circles shown in the container
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CircleContainer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_circles = <span style="color: #0033ff; font-weight: bold;">new</span> Vector.<span style="color: #000000; font-weight: bold;">&lt;</span>Circle<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Retrieve the selected object
		 *
		 * @return The selected object
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> retrieveSelectedObject<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>IStatable
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> _currentCircle;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Check whether the container has a selected object
		 *
		 * @return Boolean denoting if the container has a selected object
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> hasSelectedObject<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000000;">&#40;</span> _currentCircle <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #0033ff; font-weight: bold;">true</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">false</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Retrieve the state of the container and all contained circles
		 *
		 * @return The current state of the container, including the state's of all circles
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> retrieveState<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> xml<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;&lt;container&gt;&quot;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> _circles.<span style="color: #004993;">length</span>; i<span style="color: #000000; font-weight: bold;">++</span> <span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				xml <span style="color: #000000; font-weight: bold;">+</span>= _circles<span style="color: #000000;">&#91;</span> i <span style="color: #000000;">&#93;</span>.retrieveState<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			xml <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&lt;/container&gt;&quot;</span>;
			<span style="color: #0033ff; font-weight: bold;">return</span> xml;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Add an object to the container by it's state.
		 *
		 * @param state The state of the object to add, in this case the circle
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> addObjectByState<span style="color: #000000;">&#40;</span> state<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> circle<span style="color: #000000; font-weight: bold;">:</span>Circle = <span style="color: #0033ff; font-weight: bold;">new</span> Circle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			circle.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_DOWN</span>, circleDownListener <span style="color: #000000;">&#41;</span>;
			circle.setState<span style="color: #000000;">&#40;</span> state <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> circle <span style="color: #000000;">&#41;</span>;
			_circles<span style="color: #000000;">&#91;</span> _circles.<span style="color: #004993;">length</span> <span style="color: #000000;">&#93;</span> = circle;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Set the state of the container by adding all circles contained within the state. The container will be cleared first.
		 *
		 * @param state The new state of the container
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> setState<span style="color: #000000;">&#40;</span> state<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			clearContainer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> state.object.<span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; i<span style="color: #000000; font-weight: bold;">++</span> <span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				addObjectByState<span style="color: #000000;">&#40;</span> <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span> state.object<span style="color: #000000;">&#91;</span> i <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Clear the container of all circles
		 *
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> clearContainer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span>; i <span style="color: #000000; font-weight: bold;">&lt;</span> _circles.<span style="color: #004993;">length</span>; i<span style="color: #000000; font-weight: bold;">++</span> <span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span> _circles<span style="color: #000000;">&#91;</span> i <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			_circles.<span style="color: #004993;">splice</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span>, _circles.<span style="color: #004993;">length</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/*
		 * The following methods are all event listeners to enable the circles to be dragged
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> circleDownListener<span style="color: #000000;">&#40;</span> e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// Deselect the current circle (if there is one)</span>
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> _currentCircle <span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				_currentCircle.deselect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			_currentCircle = Circle<span style="color: #000000;">&#40;</span> e.<span style="color: #004993;">currentTarget</span> <span style="color: #000000;">&#41;</span>;
			_currentCircle.<span style="color: #004993;">select</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_MOVE</span>, circleMouseMoveListener <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_UP</span>, circleMouseUpListener <span style="color: #000000;">&#41;</span>;
&nbsp;
			_dragOffset = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span> _currentCircle.<span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #004993;">mouseX</span>, _currentCircle.<span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #004993;">mouseY</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> circleMouseMoveListener<span style="color: #000000;">&#40;</span> e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_currentCircle.<span style="color: #004993;">x</span> = <span style="color: #004993;">mouseX</span> <span style="color: #000000; font-weight: bold;">+</span> _dragOffset.<span style="color: #004993;">x</span>;
			_currentCircle.<span style="color: #004993;">y</span> = <span style="color: #004993;">mouseY</span> <span style="color: #000000; font-weight: bold;">+</span> _dragOffset.<span style="color: #004993;">y</span>;
			e.<span style="color: #004993;">updateAfterEvent</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> circleMouseUpListener<span style="color: #000000;">&#40;</span> e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_MOVE</span>, circleMouseMoveListener <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_UP</span>, circleMouseUpListener <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>Creating the Document Class</h3>
<p>The document class for this application very similar to the previous one. It was already responsible for creating the save and load buttons, creating the circle container, registering the circle container with the FileUtil and initialising the container with a default state. The only thing we need to add is the registration of the circle container with the ClipboardUtil. The full contents of this class can be seen below.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.bit101.components.PushButton;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> couk.markstar.examples.ui.CircleContainer;
	<span style="color: #0033ff; font-weight: bold;">import</span> couk.markstar.statefultoolkit.utils.ClipboardUtil;
	<span style="color: #0033ff; font-weight: bold;">import</span> couk.markstar.statefultoolkit.utils.FileUtil;
	<span style="color: #0033ff; font-weight: bold;">import</span> couk.markstar.statefultoolkit.utils.IClipboardUtil;
	<span style="color: #0033ff; font-weight: bold;">import</span> couk.markstar.statefultoolkit.utils.IFileUtil;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<span style="color: #004993;">TextField</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<span style="color: #004993;">TextFieldType</span>;
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span> <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">'#F3F3F3'</span>,<span style="color: #004993;">frameRate</span>=<span style="color: #990000;">'30'</span>,<span style="color: #004993;">width</span>=<span style="color: #990000;">'592'</span>,<span style="color: #004993;">height</span>=<span style="color: #990000;">'300'</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ClipboardExample extends <span style="color: #004993;">Sprite</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _saveButton<span style="color: #000000; font-weight: bold;">:</span>PushButton;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _loadButton<span style="color: #000000; font-weight: bold;">:</span>PushButton;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _circleContainer<span style="color: #000000; font-weight: bold;">:</span>CircleContainer;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _fileUtil<span style="color: #000000; font-weight: bold;">:</span>IFileUtil;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _clipboardUtil<span style="color: #000000; font-weight: bold;">:</span>IClipboardUtil;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Create the save and load buttons to save and load the state. Then create the circle container and register it with the FileUtil.
		 * By registering the container with the FileUtil it means the FileUtil knows which statable object to retrieve and set the state on
		 * when save and load are executed.
		 * Register the container with the ClipboardUtil so it can capture keyboard shortcuts.
		 */</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ClipboardExample<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// PushButton( parent, x, y, label, MouseEvent.CLICK event listener )</span>
			_saveButton = <span style="color: #0033ff; font-weight: bold;">new</span> PushButton<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">this</span>, <span style="color: #000000; font-weight:bold;">196</span>, <span style="color: #000000; font-weight:bold;">275</span>, <span style="color: #990000;">&quot;Save&quot;</span>, saveClickListener <span style="color: #000000;">&#41;</span>;
			_loadButton = <span style="color: #0033ff; font-weight: bold;">new</span> PushButton<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">this</span>, <span style="color: #000000; font-weight:bold;">295</span>, <span style="color: #000000; font-weight:bold;">275</span>, <span style="color: #990000;">&quot;Load&quot;</span>, loadClickListener <span style="color: #000000;">&#41;</span>;
&nbsp;
			_circleContainer = <span style="color: #0033ff; font-weight: bold;">new</span> CircleContainer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			_fileUtil = <span style="color: #0033ff; font-weight: bold;">new</span> FileUtil<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_fileUtil.registerObject<span style="color: #000000;">&#40;</span> _circleContainer <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// ClipboardUtil requires reference to the stage so it can manage the keyboard shortcuts</span>
			_clipboardUtil = <span style="color: #0033ff; font-weight: bold;">new</span> ClipboardUtil<span style="color: #000000;">&#40;</span> <span style="color: #004993;">stage</span> <span style="color: #000000;">&#41;</span>;
			_clipboardUtil.registerContainer<span style="color: #000000;">&#40;</span> _circleContainer <span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> _circleContainer <span style="color: #000000;">&#41;</span>;
&nbsp;
			initDefaultState<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> saveClickListener<span style="color: #000000;">&#40;</span> e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_fileUtil.<span style="color: #004993;">save</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> loadClickListener<span style="color: #000000;">&#40;</span> e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_fileUtil.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Initialise the circle container with four circles
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> initDefaultState<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> defaultState<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">'&lt;container&gt;'</span>;
			defaultState <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'&lt;object&gt;&lt;x&gt;196&lt;/x&gt;&lt;y&gt;100&lt;/y&gt;&lt;/object&gt;'</span>;
			defaultState <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'&lt;object&gt;&lt;x&gt;196&lt;/x&gt;&lt;y&gt;200&lt;/y&gt;&lt;/object&gt;'</span>;
			defaultState <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'&lt;object&gt;&lt;x&gt;396&lt;/x&gt;&lt;y&gt;100&lt;/y&gt;&lt;/object&gt;'</span>;
			defaultState <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'&lt;object&gt;&lt;x&gt;396&lt;/x&gt;&lt;y&gt;200&lt;/y&gt;&lt;/object&gt;'</span>;
			defaultState <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'&lt;/container&gt;'</span>;
&nbsp;
			_circleContainer.setState<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span> defaultState <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>Testing the application</h3>
<p>You will now be able to run the application and test that the state of the application can be saved and loaded and that you can copy and paste circles. The structure of the project can be seen below. If you do have any questions about the tutorial, or constructive criticism on the toolkit, don’t hesitate leave a comment below.</p>
<p style="text-align: center;"><a href="http://markstar.co.uk/blog/wp-content/uploads/2010/02/ProjectStructure.jpg"><img class="aligncenter size-full wp-image-199" title="ClipboardExampleProjectStructure" src="http://markstar.co.uk/blog/wp-content/uploads/2010/02/ProjectStructure.jpg" alt="ClipboardExample Project Structure" width="592" height="306" /></a></p>
<h3><a name="compiledapplication"></a>Compiled Application</h3>
<p>Once you have compiled the application, you should get the same output as below. Try copying and pasting the circles, you will also be able to save and load the state like before.</p>
<div class="post_flash">
<p style="text-align: center;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ClipboardExample_685686066"
			class="flashmovie"
			width="592"
			height="300">
	<param name="movie" value="http://markstar.co.uk/flash/StatefulToolkit/ClipboardExample.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://markstar.co.uk/flash/StatefulToolkit/ClipboardExample.swf"
			name="fm_ClipboardExample_685686066"
			width="592"
			height="300">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<h3><a name="sourcecode"></a>Source Files</h3>
<p>Source files are available from <a title="StatefulToolkit Downloads at GitHub" href="http://github.com/markstar/StatefulToolkit/downloads" target="_blank">GitHub</a>, under the heading ClipboardExample.</p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/actionscript/clipboard-management-using-the-statefultoolkit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s all the HYPE about?</title>
		<link>http://markstar.co.uk/blog/2009/flashplatform/actionscript/whats-all-the-hype-about/</link>
		<comments>http://markstar.co.uk/blog/2009/flashplatform/actionscript/whats-all-the-hype-about/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 19:07:39 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[HYPE]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=84</guid>
		<description><![CDATA[HYPE is a new framework for the Flash Platform that aims to help bring back the playfulness that once defined the Flash community. This post shows my experimentation using HYPE, and some information to help you get started.]]></description>
			<content:encoded><![CDATA[<p>Branden Hall and Joshua Davis have collaborated on a new framework called <a title="HYPE Framework" href="http://hype.joshuadavis.com/" target="_blank">HYPE</a>. Their aim with <a title="HYPE Framework" href="http://hype.joshuadavis.com/" target="_blank">HYPE</a> is to help bring back the playfulness that once defined the Flash community.</p>
<p style="text-align: center;"><a title="HYPE Framework Examples" href="http://hype.joshuadavis.com/" target="_blank"><img class="size-full wp-image-89 aligncenter" title="What's All The Hype About?" src="http://markstar.co.uk/blog/wp-content/uploads/2009/11/WhatsAllTheHypeAbout.jpg" alt="What's All The Hype About?" width="592" height="300" /></a></p>
<h3>Getting Started</h3>
<p>The HYPE framework lowers the barrier for people to begin playing with Flash by offering a lot of functionality out-of-the-box. It&#8217;s really easy to get started with HYPE, just download the framework from the <a title="HYPE Framework" href="http://hype.joshuadavis.com/" target="_blank">homepage</a>. They&#8217;ve even put together a nice set of <a title="HYPE Installation and Setup Instructions" href="http://hype.joshuadavis.com/installation/readme-installation-setup/" target="_blank">installation and setup instructions</a>, which shows you everything from how to install the files to adding basic functionality. Branden has also <a title="HYPE Demo: BOO!" href="http://www.vimeo.com/channels/hype#7363615" target="_blank">posted a Halloween themed tutorial</a> screencast that shows how to use some of the core functionality of HYPE.</p>
<p><span id="more-84"></span></p>
<p>There&#8217;s a plethora of examples, with code, <a title="HYPE Framework" href="http://hype.joshuadavis.com/" target="_blank">on the site</a> too. The examples vary from demonstrating <a title="SoundAnalyzer Example 01" href="http://hype.joshuadavis.com/02_examples/soundanalyzer/01_soundanalyzer/" target="_blank">sound analysis</a>, <a title="ObjectPool Example 03" href="http://hype.joshuadavis.com/02_examples/objectpool/03_objectpool/" target="_blank">object poolin</a>g and <a title="Swarm Example 04" href="http://hype.joshuadavis.com/02_examples/swarm/04_swarm/" target="_blank">swarm behaviours</a> amongst others.</p>
<h3>Extending HYPE</h3>
<p>Branden has <a title="HYPE Developer Preview" href="http://www.vimeo.com/channels/hype#7334376" target="_blank">posted a video</a> that shows the developer through the various packages within the framework. It&#8217;s really easy to create your own extensions to the framework, and I&#8217;m sure that in a few months we&#8217;ll see a lot of developers posting their own rhythms and layouts.</p>
<h3>My Experiment</h3>
<p>I&#8217;ve been looking forward to playing with the HYPE framework since Joshua and Branden started tweeting about it. I love the idea of them doing the leg work for us, allowing us to just play with code. One of the areas I&#8217;ve always been interested in is audio visualizers, and what&#8217;s really cool is that HYPE contains sound analyzers out-of-the-box. So rather than me spending days getting bogged down in code, I was able to put together the following simple visualiser in a couple of hours.</p>
<p style="text-align: center;"><a title="HYPE Sound Visualiser Example" href="http://markstar.co.uk/flash/hype/SoundAnalyser.html" target="_blank"><img class="size-full wp-image-91 aligncenter" title="Sound Equalizer Test" src="http://markstar.co.uk/blog/wp-content/uploads/2009/11/WhatsAllTheHypeAboutEqualizer.jpg" alt="Sound Equalizer Test" width="592" height="200" /></a></p>
<p>Click on the image above to see it in action, as soon as I can find a decent code plugin for wordpress I&#8217;ll post the source code.</p>
<p>I hope HYPE will gain a lot of ground amongst the community, it&#8217;s a brilliant framework with a great aim and something I&#8217;ll be playing with more in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2009/flashplatform/actionscript/whats-all-the-hype-about/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code Formatting for Flex Builder 3</title>
		<link>http://markstar.co.uk/blog/2009/flashplatform/flex/code-formatting-for-flex-builder-3/</link>
		<comments>http://markstar.co.uk/blog/2009/flashplatform/flex/code-formatting-for-flex-builder-3/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 20:33:14 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Builder 3]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Format]]></category>
		<category><![CDATA[Formatting]]></category>
		<category><![CDATA[Indent]]></category>
		<category><![CDATA[MXML]]></category>
		<category><![CDATA[Rearrange]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=57</guid>
		<description><![CDATA[Learn how to install and use the code formatter plug-in for Flex Builder 3. The plug-in formats, indents and rearranges both MXML and ActionScript code.]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been introduced to a code formatter for Flex Builder 3 and thought it was worth sharing. The plug-in formats, indents and rearranges both MXML and ActionScript code.</p>
<p style="text-align: center;"><a href="http://markstar.co.uk/blog/wp-content/uploads/2009/09/CodeFormattingForFlexBuilder3.jpg"><img class="alignnone size-full wp-image-64" title="Code Formatting for Flex Builder 3" src="http://markstar.co.uk/blog/wp-content/uploads/2009/09/CodeFormattingForFlexBuilder3.jpg" alt="Code Formatting for Flex Builder 3" width="592" height="294" /></a></p>
<h3>Downloading the plug-in</h3>
<p>There is a version of the plug-in <a title="Flex Formatter Project on Source Forge" href="http://sourceforge.net/projects/flexformatter/" target="_blank">available here</a>, but I haven&#8217;t installed it from there. Below I&#8217;ve included instructions on how to install the plug-in using the software updates feature in Flex Builder.<span id="more-57"></span></p>
<h3>Installing the plug-in via Software Updates</h3>
<ol>
<li>Launch Flex Builder 3 and go to <strong><em>Help</em></strong>&gt;<strong><em>Software Updates</em></strong>&gt;<strong><em>Find and install&#8230;</em></strong></li>
<li>Check the <strong><em>Search for new features to install</em></strong> option and click <strong><em>Next</em></strong></li>
<li>Now create a <strong><em>New Remote Site&#8230;</em></strong></li>
<li>Enter the following URL for the remote site and give it a name, such as <strong><em>Flex Code Formatter</em> </strong>and click <strong><em>Finish</em></strong>:<br />
<strong><em>http://flexformatter.googlecode.com/svn/trunk/FlexFormatter/FlexPrettyPrintCommandUpdateSite</em></strong></li>
<li>Browse the tree to find the code formatter plugin ( <strong><em>FlexPrettyPrintCommandFeature Feature 0.6.27</em></strong> ) and click <strong><em>Next</em></strong>.</li>
<li>Accept the license agreement and click <strong><em>Next</em></strong> then <strong><em>Finish</em></strong>.</li>
<li>Click <strong><em>Install All</em></strong> and restart Flex Builder 3. The plug-in is now installed and ready to use.</li>
</ol>
<h3>Using the plug-in</h3>
<p>Once Flex Builder has restarted you should notice a new toolbar with some black and white icons. This toolbar gives you access to the following features:</p>
<ul>
<li>Generating ASDoc comments for the file</li>
<li>Generating ASDoc comment for the current element</li>
<li>Format code</li>
<li>Indent code</li>
<li>Rearrage the code of the file</li>
</ul>
<p>There will also be a shortcut key set up for formatting code; the default is <strong><em>CTRL</em></strong>+<strong><em>SHIFT</em></strong>+<strong><em>F</em></strong>.</p>
<h3>Editing the Preferences</h3>
<p>To edit the preferences of the plugin go to <strong><em>Window</em></strong>&gt;<strong><em>Preferences</em></strong>. Then browse to <strong><em>Flex Formatting</em></strong> using the tree navigation on the left. There are a vast array of formatting and restructuring options available, so you should be able to find something to suit the way you code. It is also worth browsing the navigation tree to show the options for <strong><em>Auto Format</em></strong>; this will give you the option to format or indent code when you save.</p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2009/flashplatform/flex/code-formatting-for-flex-builder-3/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>