<?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; Flash Platform</title>
	<atom:link href="http://markstar.co.uk/blog/category/flashplatform/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>Twitter Search Demo using Robotlegs, Signals and the Application Signal Bus</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/twitter-search-demo-using-robotlegs-signals-and-the-application-signal-bus/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/twitter-search-demo-using-robotlegs-signals-and-the-application-signal-bus/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 22:00:26 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Robotlegs]]></category>
		<category><![CDATA[ApplicationSignalBus]]></category>
		<category><![CDATA[AS3-Signals]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Signals]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=302</guid>
		<description><![CDATA[I've been using Robotlegs and Signals recently and they really are awesome to work with however I still had to create a Signal for each Signal that was dispatched through the application, which is more times than you would need to create a custom event. This post shows an example of a solution to this problem.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Robotlegs and Signals recently and they really are awesome to work with however I still had to create a Signal for each Signal that was dispatched through the application, which is more times than you would need to create a custom event. I was thinking about an approach to get around this problem when I saw some tweets from <a title="DestroyToday (Jonnie Hallman) on Twitter" href="http://twitter.com/destroytoday" target="_blank">Jonnie Hallman</a> about an Application Signal Bus. Luckily he was kind enough to post the following gist to demonstrate.<br />
<span id="more-302"></span><br />
<script src="http://gist.github.com/329590.js"></script><br />
So I thought I&#8217;d update my <a title="Twitter Search Demo using Robotlegs and Signals" href="http://markstar.co.uk/blog/2010/flashplatform/twitter-search-demo-using-robotlegs-and-signals/" target="_blank">Twitter Search Demo</a> to demonstrate how it could be used. As with the previous posts, click the image below to view the demo. View source is enabled and I’ve included everything for you to compile.</p>
<p style="text-align: center;"><a href="http://markstar.co.uk/flash/Robotlegs/TwitterSearchSignalBus/TwitterSearchSignalBus.html" target="_blank"><img class="aligncenter size-full wp-image-309" title="Twitter Search Demo using the ApplicationSignalBus" src="http://markstar.co.uk/blog/wp-content/uploads/2010/03/TwitterSearchDemoApplicationSignalBus.jpg" alt="Click to view Twitter Search Demo using the ApplicationSignalBus" width="300" height="495" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/twitter-search-demo-using-robotlegs-signals-and-the-application-signal-bus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Twitter Search Demo using Robotlegs and Signals</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/twitter-search-demo-using-robotlegs-and-signals/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/twitter-search-demo-using-robotlegs-and-signals/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 12:00:09 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Robotlegs]]></category>
		<category><![CDATA[AS3-Signals]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Signals]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=292</guid>
		<description><![CDATA[In light of my recent post about why Robotlegs benefits from AS3-Signals I thought it was only fitting that I updated my Twitter Search demo.]]></description>
			<content:encoded><![CDATA[<p>In light of my recent post about <a title="Why Robotlegs benefits from AS3-Signals" href="http://markstar.co.uk/blog/2010/flashplatform/why-robotlegs-benefits-from-as3-signals/" target="_blank">why Robotlegs benefits from AS3-Signals</a> I thought it was only fitting that I updated my Twitter Search demo! This was really easy to do; partly because the demo is so small. It also allowed me to use interfaces to reference view components in the mediators (one of the advantages of using Signals). The use of interfaces makes it really easy to swap out the view for something different, like a mobile version, without changing any core functionality. Anyway, click the image below to view the demo; view source is enabled and I&#8217;ve included the libs and html-template folders this time so it should be easier for you to compile!</p>
<p><span id="more-292"></span></p>
<p style="text-align: center;"><a href="http://markstar.co.uk/flash/Robotlegs/TwitterSearchSignals/TwitterSearchSignals.html" target="_blank"><img class="aligncenter size-full wp-image-293" title="Twitter Search Demo using Signals" src="http://markstar.co.uk/blog/wp-content/uploads/2010/03/TwitterSearchDemoSignals.jpg" alt="Click to view Twitter Search Demo using Signals" width="300" height="495" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/twitter-search-demo-using-robotlegs-and-signals/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Why Robotlegs benefits from AS3-Signals</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/why-robotlegs-benefits-from-as3-signals/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/why-robotlegs-benefits-from-as3-signals/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 09:00:27 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Robotlegs]]></category>
		<category><![CDATA[AS3-Signals]]></category>
		<category><![CDATA[Signals]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=282</guid>
		<description><![CDATA[This post discusses one of the benefits of using AS3-Signals with Robotlegs over the standard Event model.]]></description>
			<content:encoded><![CDATA[<h3>My problem with using the Event Model and Robotlegs</h3>
<p>One of the things that bugs me about the use of the event model with <a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> is that Mediators are tightly coupled with the views. Take my <a title="Twitter Search Demo using Robotlegs and Events" href="http://markstar.co.uk/blog/?p=261" target="_blank">Twitter Search Demo</a> for example, the SearchEntryMediator class expects an instance of the SearchEntry class as its view, see below.</p>
<p><span id="more-282"></span></p>
<p><script src="http://gist.github.com/324461.js"></script></p>
<p>One suggestion could be type the view to an interface in the mediator, but this is too loosely coupled because an interface cannot define the events an object can dispatch. There are a few solutions to this issue, for example we could use function callbacks, however <a title="Robert Penner on Twitter" href="http://twitter.com/robpenner/" target="_blank">Robert Penner</a> has come up with a better solution, <a title="AS3-Signals at GitHub" href="http://github.com/robertpenner/as3-signals" target="_blank">AS3-Signals</a>.</p>
<h3>The solution: AS3-Signals</h3>
<p><a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> and <a title="AS3-Signals at GitHub" href="http://github.com/robertpenner/as3-signals" target="_blank">AS3-Signals</a> work really well together, especially with the introduction of the <a title="Command Signal Extension at GitHub" href="http://github.com/joelhooks/signals-extensions-CommandSignal" target="_blank">Command Signal Extension</a>. Each of these libraries don&#8217;t rely on string constants to function, they are strongly typed, therefore the compiler is able to throw errors much sooner if something is wrong.</p>
<p>A Signal gives an event a concrete membership in a class, for this reason we are able to include Signals in interfaces. Using this the SearchEntryMediator in my <a title="Twitter Search Demo using Robotlegs and Events" href="http://markstar.co.uk/blog/?p=261" target="_blank">Twitter Search Demo</a> can type the view to an ISearchEntry, and any class that implements this interface must include the searchRequested signal, see below.</p>
<p><script src="http://gist.github.com/324470.js"></script></p>
<p>The interface is very simple and just defines the searchRequested signal.</p>
<p><script src="http://gist.github.com/324484.js"></script></p>
<h3>Why bother?</h3>
<p>It&#8217;s a good question, why should we go to the effort of creating interfaces for our views? We could quite easily continue to use the Event model with Robotlegs and it would work, but the use of interfaces would be beneficial for a multi-platform Flash application or for a workflow that involved more than one person.</p>
<p>Imagine an application that is to be deployed to many different devices that have various screen sizes, some can use a mouse, some can be touch enabled and some are restricted to keys. To create the best user experience you would want the view of your application, and the interaction with that view, to be tailored to that device. By using interfaces for our views we can use the same code base for all applications but have different views for each device; as long as our views implement our interfaces the application will work. More advantages to this are seen if different people implement the views; by using Signals in the interface the person developing the view must implement them whereas there&#8217;s nothing specify that the person must implement an event.</p>
<p>P.S It&#8217;s also worth noting that there are many other benefits to using AS3-Signals, for example they provide <a title="AS3-Signals performance tests" href="http://alecmce.com/as3/events-and-signals-performance-tests" target="_blank">significant speed improvements</a> over using Events, not just the ability to define them in interfaces.</p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/why-robotlegs-benefits-from-as3-signals/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Twitter Search Demo using Robotlegs and Events</title>
		<link>http://markstar.co.uk/blog/2010/flashplatform/flex/twitter-search-demo-using-robotlegs/</link>
		<comments>http://markstar.co.uk/blog/2010/flashplatform/flex/twitter-search-demo-using-robotlegs/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 15:13:42 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Robotlegs]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Event Model]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://markstar.co.uk/blog/?p=261</guid>
		<description><![CDATA[I've had chance to play with Robotlegs this weekend and have really enjoyed it. This post shows a quick demo I've put together using Robotlegs and the Twitter Search API.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had chance to play with <a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">Robotlegs</a> this weekend and have really enjoyed it. It&#8217;s really lightweight and you find that you spend more time coding rather than repeating the same tasks like you would do in other frameworks.</p>
<p>The first demo I put together was a simple <a title="TwitterSearch Demo" href="http://markstar.co.uk/flash/Robotlegs/TwitterSearch/TwitterSearch.html" target="_blank">Twitter Search application</a>, using the <a title="Twitter Search API documentation" href="http://apiwiki.twitter.com/Twitter-API-Documentation" target="_blank">Twitter Search API</a>. You can see the demo in all it&#8217;s glory by clicking the image below! View Source is enabled so you can download the source and have a play; you will need the Robotlegs SWC to compile though, you&#8217;ll find this on the <a title="Robotlegs website" href="http://www.robotlegs.org/" target="_blank">Robotlegs website</a>. If you have any feedback or questions please leave a comment below!<br />
<span id="more-261"></span></p>
<p style="text-align: center;"><a title="Click to view the Twitter Search demo" href="http://markstar.co.uk/flash/Robotlegs/TwitterSearch/TwitterSearch.html" target="_blank"><img class="size-full wp-image-264 aligncenter" title="Click to view the Twitter Search demo" src="http://markstar.co.uk/blog/wp-content/uploads/2010/03/TwitterSearchDemo.jpg" alt="Click to view the Twitter Search demo" width="300" height="400" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://markstar.co.uk/blog/2010/flashplatform/flex/twitter-search-demo-using-robotlegs/feed/</wfw:commentRss>
		<slash:comments>1</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_35207519"
			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_35207519"
			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_1092540420"
			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_1092540420"
			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>
	</channel>
</rss>