<?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>Mark Kirby - Mobile Developer &#187; tutorial</title>
	<atom:link href="http://mark-kirby.co.uk/category/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://mark-kirby.co.uk</link>
	<description>I'm a user focused mobile developer, here is where I publish advice and thoughts on building great mobile apps</description>
	<lastBuildDate>Thu, 29 Jul 2010 10:18:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Structuring Flash Lite code the MVC way</title>
		<link>http://mark-kirby.co.uk/2009/structuring-flash-lite-code-the-mvc-way/</link>
		<comments>http://mark-kirby.co.uk/2009/structuring-flash-lite-code-the-mvc-way/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 12:25:29 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=538</guid>
		<description><![CDATA[Advice on how to structure your Flash and Flash Lite code in an MVC way, also taking principles of build from Java's ANT tool. Aimed at those already using classes to develop Flash Lite code.]]></description>
			<content:encoded><![CDATA[<p>I recently had a discussion with Thomas Joos on ways of structuring code that conform to basic standards. Taking his ideas on board and combining them with some of my own, I propose this simple structure which can serve as the starting point for a new Flash Lite or Flash project. This is based on the MVC model, and ANT for JAVA.</p>
<h2>The root</h2>
<p>The root of your project could contain the following folders:</p>
<ul>
<li>build</li>
<li>deploy</li>
<li>src</li>
</ul>
<p>Here&#8217;s more details on each</p>
<h3>build</h3>
<p>The build folder is for your Flash output, generated during the build process.</p>
<p>You can set this folder in Flash CS4 by opening the .fla file and going to : &#8220;File -&gt; Publish settings&#8230;&#8221; in the menu, and then navigating to the build folder to set the file for the Flash type in the popup which comes up.</p>
<p>The build folders contents should be able to be deleted at any time, and recreated by running the build. Do not keep any source files or the .fla in here!</p>
<h3>deploy</h3>
<p>The deploy folder is a good place to keep your installers, such as the .sis files produced by the Adobe Mobile Packager, or other packagers.</p>
<h3>src</h3>
<p>The src folder is the place to keep your source code, that&#8217;s your .fla and related .as files, structured as explained in the following section.</p>
<h2>The source code folder</h2>
<p>As mentioned, all your source code should be kept in the src folder.</p>
<p>The structure of src folder will look something like this:</p>
<ul>
<li>com</li>
<ul>
<li>companyName</li>
<ul>
<li>appName</li>
<ul>
<li>controller</li>
<li>model</li>
<li>view</li>
<li>main.as</li>
</ul>
<li>utils</li>
<li>components</li>
</ul>
</ul>
<li>appName.fla</li>
</ul>
<p>So your .fla file goes into the root of src, alongside a folder structure unique to your company, which will also be reflected in the namespaces you give your classes.</p>
<p>The classes specific to the app go within a folder with the same name as the app, and the classes which can be used in other applications are placed alongside this folder in their own folders. I&#8217;ll go into more detail on the contents of each folder next. </p>
<h3>appName</h3>
<p>Within the appName folder, you place the classes which cannot be reused in other applications and are specific to this application. These will form the core of this individual application.</p>
<p>You will also place a main.as file here which will be called from the .fla file and will call the various controllers to manage the app.</p>
<h4>model</h4>
<p>In the model folder you store datatypes declaring data formats used within the app, as well as perhaps classes to manage arrays of data stored and kept in memory whilst the app is running.</p>
<h4>view</h4>
<p>In the view folder you store classes relating to screens as well as components that you only want to use within this app.</p>
<h4>controller</h4>
<p>In the controller folder you can store classes relating to the logic of the programme, a key controller to manage what key is pressed and when, a screen controller to manage what screen is currently being displayed, perhaps an API controller to manage all the API calls. The classes here will work closely with the view and the model, building views and manipulating the model. They will be called initially from your main.as class.</p>
<h3>utils</h3>
<p>Within the utils folder you place helpers and utilities which can be reused in other apps. You should be able to drop classes in here and just start reusing them.</p>
<h3>components</h3>
<p>Within the components folder you place classes which relate to visual components of your app, stored in the library of the .fla. These components classes, although may come with different assets in another app, can always be reused and will always behave in the same way when placed in another app.</p>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2009/structuring-flash-lite-code-the-mvc-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to debug the Shared Object in Device Central</title>
		<link>http://mark-kirby.co.uk/2009/how-to-debug-the-shared-object-in-device-central/</link>
		<comments>http://mark-kirby.co.uk/2009/how-to-debug-the-shared-object-in-device-central/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 15:23:23 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=532</guid>
		<description><![CDATA[How to access the shared object in Device Central for debugging purposes. Not a simple method, but one that works nonetheless.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick tutorial explaining how to inspect and debug the shared object created on device central when running tests on Flash Lite apps. Its not simple and took me some work to figure out. If you know a better way, please let me know.</p>
<p>This tutorial is aimed at OS X 10.5 users, with Device Central CS4.</p>
<h2>1 &#8211; Get a capable unarchiver</h2>
<p>You need a file unarchiver which can cope with .cpgz files. The only one I could find was <a href="http://echoone.com/filejuicer/">File Juicer</a> which costs around $12 &#8211; if anyone finds a free one, let me know.</p>
<h2>2 &#8211; Extract the Shared Object file</h2>
<p>Navigate to your home folder and &#8220;Library/Application Support/Adobe/Adobe Device Central CS4&#8243;.</p>
<p>Locate the file named storageObjects.bin and drag it onto the File Juicer icon in your apps.</p>
<p>A folder should appear named &#8220;Storage Objects Juice&#8221;, containing a folder named &#8220;txt&#8221;, containing a file called something like StorageObject(xx% copy)-1.txt &#8211; this is the file you&#8217;ll need.</p>
<h2>3 &#8211; Interpreting the StorageObject file</h2>
<p>Open the txt file with your editor of choice. You will see likely see lots of text, expand the text editor to fill your screen to make things easier.</p>
<p>This file contains reference to all saved shared objects, so to see the latest you need to be at the bottom of the file.</p>
<p>Look for codes resembling &#8220;B81FA49052AAA2BD750992BCFD03478D 8144600B02252A799C14CCE2BC9F50B6 ø TCSO &#8221; &#8211; this appears to be the delimiter between shared object sessions. </p>
<p>Directly following each of delimiter you will find the name of your shared object, the name of the shared object element, and any data saved. </p>
<p>The layout isn&#8217;t great, line breaks are seemingly random, and its clear this file was not meant for human consumption. Until Adobe add a Shared Object inspector to Device Central, its all we got though, as far as I know.</p>
<p>Anyone got an easier method?</p>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2009/how-to-debug-the-shared-object-in-device-central/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing a Flash Lite Client for a REST API</title>
		<link>http://mark-kirby.co.uk/2009/writing-a-flash-lite-client-for-a-rest-api/</link>
		<comments>http://mark-kirby.co.uk/2009/writing-a-flash-lite-client-for-a-rest-api/#comments</comments>
		<pubDate>Fri, 29 May 2009 14:12:28 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=515</guid>
		<description><![CDATA[Advice on writing a Flash Lite client for a REST API. Covers limitations of Flash Lite, changes you might need to make to your API, reasons someone else's API might not work, and pointers on how to GET and POST data.]]></description>
			<content:encoded><![CDATA[<p>This tutorial explains how to create a flash REST API client that works with Actionscript 2 and Flash Lite 3.1+. Its not as simple as you might think, but the most complex part is knowing and understanding all the restrictions, many of which I&#8217;ve outlaid here.</p>
<h2>API restrictions</h2>
<p>Unfortunately there are some restrictions within Flash Lite which means you will only be able to access certain API&#8217;s. Before continuing, ensure the API you are trying to access meets the following criteria. If its your API, you are in luck, you can fix these issues.</p>
<h3>Crossdomain Policy</h3>
<p>You will need to be accessing an API which has a crossdomain policy file in place. If you own the API you can <a href="http://www.moock.org/asdg/technotes/crossDomainPolicyFiles/">create one</a>. If not you will need to create a proxy &#8211; although that&#8217;s out of scope of this tutorial.</p>
<h3>Authentication</h3>
<p>Flash Lite does not work with HTTP header based security using the &#8220;Authorize&#8221; header. The function for adjusting headers &#8211; XML.addRequestHeader has a bug. In addition, you cannot use the addRequestHeader feature unless you are making a POST request, bug or no bug. This means for GET request you need to find another way of authenticating anyway. If the API you have access to doesn&#8217;t allow any other means of authentication, you won&#8217;t be able to write a Flash Lite client. </p>
<p>If you have control of the API, ensure it can read the user credentials from the URL for GET requests, and from either the URL or parameter body for POST requests. That way you can avoid having to use addRequestHeader. </p>
<h3>HTTP Status codes</h3>
<p>Flash can&#8217;t easily interpret HTTP status codes. The API should therefore have an option for returning status in either an XML or string format. The HTTP status should always be 200, with the actual success code returned in the body of the content. This code can then be interpreted by Flash. </p>
<p>Please note, for POST&#8217;s, the status returned should be of the same type (either XML or string) as the data posted. So in other words if you pass XML to the API to POST data, the status should be returned as XML, if you pass name key pairs to POST data, the status should be returned as a plain text name key pair (e.g. name=xxxx). If the API interprets POSTed data in chunks of XML, it should return the status as XML. This enables you to use either XML.sendAndLoad to send and read XML or LoadVars.sendAndLoad to send and read variables. You can&#8217;t (as far as I can tell) send XML and read variables, or send variables and read XML. </p>
<h3>PUT and DELETE</h3>
<p>You can&#8217;t make PUT and DELETE requests from Flash (or indeed any browser), so you will need to ensure your API uses overloaded POST. That is, you can specify the PUT or DELETE method in the POST url and the API interprets it, or you can make edits and deletes through the basic POST or GET functions.</p>
<h2>Flash Lite checklist</h2>
<p>You will need to make a few updates to your app before connecting to the API.</p>
<h3>Playback settings</h3>
<p>Ensure you have set the playback settings to access network only (File in top menu -> Publish Settings option -> Flash tab -> Advanced section -> Local playback security dropdown -> set to Access network only)</p>
<h3>Device central</h3>
<p>Ensure you have selected a Flash Lite 3.1 device in Device Central for testing.</p>
<p>Ensure under the device central security settings you have selected &#8220;Local Trusted Sandbox&#8221;.</p>
<h3>Flash Lite security settings</h3>
<p>When testing on a device as a swf, if you find network errors, ensure the swf is placed inside the Flash Lite trusted folder, if available. Location of the trusted folder will vary from device to device, but for Nokia&#8217;s N95 its located in C:/Data/Others/Trusted. Note that the Others folder may appear as Other without the s &#8211; this is not an issue. If you can&#8217;t find the Trusted folder inside Other(s), create it. To access the swf from the device just navigate directly to C:/Other(s), the data folder won&#8217;t appear within the phone view. There&#8217;s more on this topic on <a href="http://bloggy.kuneri.net/2008/05/13/the-pain-of-flash-lite-30">Kuneri Bloggy</a>.</p>
<h2>Making a GET request</h2>
<p>To perform a GET request, returning XML you use the <a href="http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=Part2_AS2_LangRef_1.html">XML.load</a> method. </p>
<p>[code lang="actionscript"]<br />
var my_xml:XML = new XML();</p>
<p>my_xml.onLoad = function(success:Boolean) {</p>
<p>    var endTime:Number = getTimer();</p>
<p>    var elapsedTime:Number = endTime-startTime;</p>
<p>    if (success) {<br />
	    trace("xmlDecl:"+my_xml.xmlDecl);<br />
	    trace("contentType:"+my_xml.contentType);<br />
	    trace("docTypeDecl:"+my_xml.docTypeDecl);<br />
            trace("packet:"+my_xml.toString());<br />
    } else {<br />
	    trace("Unable to load remote XML.");<br />
    }</p>
<p>    trace("loaded in: "+elapsedTime+" ms.");</p>
<p>};<br />
my_xml.load("http://api.url.com/user/1.xml");<br />
[/code]</p>
<p>You get the idea, you could create a text field to output the data on the device, manipulate the xml etc.</p>
<p>To perform a GET request returning name value pairs, you use the <a href="http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=Part2_AS2_LangRef_1.html">LoadVars.load</a> method.</p>
<p>[code lang="actionscript"]<br />
var myLoadVars:LoadVars = new LoadVars();<br />
myLoadVars.onLoad = function(success:Boolean) {<br />
    if (success) {<br />
        trace(this.toString());<br />
    } else {<br />
        trace("Error loading/parsing LoadVars.");<br />
    }<br />
};<br />
myLoadVars.load("http://api.url.com/user/1.json");<br />
[/code]</p>
<h2>POST request</h2>
<p>To make a POST request by sending name value pairs and processing a returned status code in name value format, you use the <a href="http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=Part2_AS2_LangRef_1.html">LoadVars.sendAndLoad</a> method.</p>
<p>In this example we are posting a name value pair of &#8220;name=New Category&#8221;, with the server interpreting the field name, and returning either &#8220;error=404&#8243; or &#8220;status=200&#8243; as plain text output. The code interprets either the error or the status and traces it out to the console. You would probably interpret it in some way and do something more with it.</p>
<p>[code lang="actionscript"]<br />
var resultLoadVars:LoadVars = new LoadVars();<br />
resultLoadVars.onLoad = function(success:Boolean) {<br />
	if (success) {<br />
		if (resultLoadVars.error !== undefined) {<br />
        	trace("error: "+result_lv.error);<br />
		}<br />
		if (resultLoadVars.status !== undefined) {<br />
        	trace("status: "+result_lv.status);<br />
		}<br />
	} else {<br />
    	trace("Error connecting to server.");<br />
	}<br />
};<br />
var send_lv:LoadVars = new LoadVars();<br />
send_lv.name = "New Category";<br />
send_lv.sendAndLoad("http://api.url.com/user/1", result_lv, "POST");<br />
[/code]</p>
<p>To make a POST request by sending XML and processing a returned status code in XML format, you use the <a href="http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=Part2_AS2_LangRef_1.html">XML.sendAndLoad</a> method.</p>
<p>In this example we are posting xml containing the tag name with content &#8220;New Category&#8221;, with the server interpreting the field name, and returning either an error tag with the code &#8220;404&#8243; or  a status tag with the code &#8220;200&#8243; as XML. The code interprets either the error or the status and traces it out to the console. You would probably interpret it in some way and do something more with it.</p>
<p>[code lang="actionscript"]<br />
var dataToPost:String = "<name>New Category</name>";<br />
var my_xml:XML = new XML(dataToPost);<br />
var myReply_xml:XML = new XML();<br />
myReply_xml.ignoreWhite = true;<br />
myReply_xml.onLoad = myOnLoad;<br />
my_xml.sendAndLoad("http://api.url.com/user/1", myReply_xml);<br />
function myOnLoad(success:Boolean) {<br />
    if (success) {<br />
        if ((myReply_xml.firstChild.nodeName == "error")) {<br />
            trace("error: "+myReply_xml.firstChild);<br />
        }<br />
        if ((myReply_xml.firstChild.nodeName == "status")) {<br />
            trace("status: "+myReply_xml.firstChild);<br />
        }<br />
    } else {<br />
       trace("Error connecting to server.");<br />
    }<br />
}<br />
[/code]</p>
<h2>Next steps</h2>
<p>Don&#8217;t worry too much about following the code examples here, follow the links to the adobe documentation and see if you can get the code to work with the API you have. I&#8217;m starting out in this area too &#8211; so have really just presented my initial findings after a couple of days research &#8211; hopefully this will save some of you that time at least! Leave issues or problems with specific devices, links to better ways of doing things or suggestions in the comments. </p>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2009/writing-a-flash-lite-client-for-a-rest-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASUnit with FlashLite 2.x and 3.x</title>
		<link>http://mark-kirby.co.uk/2009/asunit-with-flashlite/</link>
		<comments>http://mark-kirby.co.uk/2009/asunit-with-flashlite/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 13:55:56 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=492</guid>
		<description><![CDATA[How to set up ASUnit for unit testing Flash Lite. Works with FlashLite 2.x and above. We focus on how to install the ASUnit framework, where to place your tests and how to run the tests, along with links to how to write the tests.]]></description>
			<content:encoded><![CDATA[<p>The tutorial explains a simple way to get started with ASUnit for unit testing your Flash Lite apps. There are many different ways of setting up ASUnit, but rather than be open and vague I&#8217;m going to prescribe a specific method which I feel separates your tests from the framework nicely, whilst being quick and easy to set up at the same time. Once you manage this, you&#8217;ll soon find your favourite method.</p>
<p>Please note &#8211; this method will also work with all Actionscript 2.0 Flash 8 apps.</p>
<h2>1 &#8211; Download and install the ASUnit Framework</h2>
<p><a href="http://asunit.org/">Download the latest version of the code</a>.</p>
<p>Unpackage and locate the folder named &#8216;as25&#8242;.</p>
<p>Copy this folder &#8216;as25&#8242; into the classpath (the root folder containing the code files) of your app.</p>
<p>Create another folder in the classpath called &#8216;tests&#8217;.</p>
<p>I&#8217;m assuming the classpath also contains all your components, classes etc, or if you have yet to code, its empty.</p>
<p>Here&#8217;s the contents of my root folder so you can follow my examples:</p>
<p>* AppName.fla (file)<br />
* _classpath (folder, containing all my .as files)<br />
** as25 (folder)<br />
** tests (folder)<br />
** other .as files</p>
<h2>2 &#8211; Set up the ASUnitRunner app</h2>
<h3>2a &#8211; Copy the ASUnitRunner.fla and open it</h3>
<p>Copy the ASUnitRunner.fla file to the same location as your apps fla file/s.</p>
<p>My folder now looks like this:</p>
<p>* AppName.fla (file)<br />
<strong>* ASUnitRunner.fla (file)</strong><br />
* _classpath (folder, containing all my .as files)<br />
** as25 (folder)<br />
** tests (folder)<br />
** other .as files</p>
<p>Open the newly moved ASUnitRunner file with your editor.</p>
<h3>2b &#8211; Set the publish settings</h3>
<p>Open publish settings and set the .swf to be published in your chosen location. </p>
<p>Alternatively you can create a folder called bin in the same folder the ASUnitRunner is sitting in, and it will automatically publish in there.</p>
<h3>2c &#8211; Set the classpath</h3>
<p>Open the Actionscript settings (in CS4 its File -> Publish Settings -> Flash -> Script settings button). </p>
<p>Remove both classpaths currently in place.</p>
<p>Set one class path pointing to the src folder within the as25 folder starting from the location of the fla e.g.</p>
<p>[code lang="bash"]<br />
./path/to/as25/src<br />
[/code]</p>
<p>in my case:</p>
<p>[code lang="bash"]<br />
./_classpath/as25/src<br />
[/code]</p>
<p>Set another class path pointing to the classpath root starting from the location of the fla e.g.</p>
<p>in my case:<br />
[code lang="bash"]<br />
./_classpath<br />
[/code]</p>
<h3>2d &#8211; Set the action to the right folder</h3>
<p>Open the first frame of the fla and change it to:</p>
<p>[code lang="bash"]<br />
import tests.AsUnitRunner;<br />
AsUnitRunner.main(this);<br />
[/code]</p>
<h2>3 &#8211; Set up the tests folder</h2>
<h3>3a &#8211; copy test files</h3>
<p>There are 2 more files to copy over into your tests folder.</p>
<p>Copy &#8216;as25/test/AllTests.as&#8217; to &#8216;tests/AllTests.as&#8217;</p>
<p>Copy &#8216;as25/test/AsUnitRunner.as&#8217; to &#8216;tests/AsUnitRunner.as&#8217;</p>
<h3>3b &#8211; Add correct paths to AllTests.as</h3>
<p>AllTests is set up to test ASUnit itself &#8211; so we will update it to test a sample file we will create.</p>
<p>Change tests/AllTests.as to:<br />
[code lang="actionscript"]<br />
class tests.components.AllTests extends asunit.framework.TestSuite {<br />
	private var className:String = "AllTests";</p>
<p>	public function AllTests() {<br />
		super();<br />
		addTest(new tests.components.ExampleTest());<br />
	}<br />
}<br />
[/code]</p>
<h3>3c &#8211; Add correct paths to AsUnitRunner.as</h3>
<p>Change tests/AsUnitRunner.as to:</p>
<p>[code lang="actionscript"]<br />
import asunit.textui.TestRunner;<br />
import tests.AllTests;</p>
<p>class tests.AsUnitRunner extends TestRunner {</p>
<p>	public static function main(container:MovieClip) : Void {<br />
		var tR = new AsUnitRunner();<br />
	}</p>
<p>	public function AsUnitRunner() {<br />
		start(AllTests);<br />
	}<br />
}<br />
[/code]</p>
<h2>4 &#8211; Create sample file to test along with some tests</h2>
<h3>4a &#8211; Create components/Example.as</h3>
<p>Create a folder called components at the root of your classpath, for me thats:</p>
<p>* AppName.fla (file)<br />
* ASUnitRunner.fla (file)<br />
* _classpath (folder, containing all my .as files)<br />
** as25 (folder)<br />
** tests (folder)<br />
<strong>** components (folder)</strong><br />
** other .as files</p>
<p>Create a new file called Example.as and place it inside the components with the following code:<br />
[code lang="actionscript"]</p>
<p>class components.Example {</p>
<p>	public function Example() {<br />
	}</p>
<p>}<br />
[/code]</p>
<h3>4b &#8211; Create tests/components/AllTests and ExampleTest</h3>
<p>Create a folder within your tests folder called components, for me thats:</p>
<p>* AppName.fla (file)<br />
* ASUnitRunner.fla (file)<br />
* _classpath (folder, containing all my .as files)<br />
** as25 (folder)<br />
** tests (folder)<br />
<strong>*** components (folder)</strong><br />
** components (folder)<br />
** other .as files</p>
<p>Create the following two files:</p>
<p>AllTests.as<br />
[code lang="actionscript"]<br />
class tests.components.AllTests extends asunit.framework.TestSuite {<br />
	private var className:String = "AllTests";</p>
<p>	public function AllTests() {<br />
		super();<br />
		addTest(new tests.components.ExampleTest());<br />
	}<br />
}<br />
[/code]</p>
<p>ExampleTest.as<br />
[code lang="actionscript"]<br />
import components.Example;<br />
import asunit.framework.TestCase;</p>
<p>class tests.components.ExampleTest extends TestCase {<br />
	private var className:String = "ExampleTest";<br />
	private var instance:Example;</p>
<p>	public function ExampleTest(testMethod:String) {<br />
		super(testMethod);<br />
	}</p>
<p>	public function setUp():Void {<br />
		instance = new Example();<br />
	}</p>
<p>	public function tearDown():Void {<br />
		delete instance;<br />
	}</p>
<p>	public function testInstantiated():Void {<br />
		assertTrue("Example instantiated", instance instanceof Example);<br />
	}</p>
<p>	public function test():Void {<br />
		assertTrue("failing test", false);<br />
	}<br />
}<br />
[/code]</p>
<h2>5 &#8211; Run your tests</h2>
<p>Now you are all set up, time to run those tests.</p>
<p>Simply publish and run AsUnitRunner.fla.</p>
<p>Expect to see a failure, the dummy test is set up expected to fail. </p>
<p>Now you can see how to set up ASUnit, you can expand Example.as and add some functions to test, and play around until you are ready to test your own functions. <a href="http://www.flashcodersny.org/wordpress/?p=103">Advice on how to write tests can be found here</a>. I hope to add another tutorial on this soon. </p>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2009/asunit-with-flashlite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML standards cheatsheet</title>
		<link>http://mark-kirby.co.uk/2009/xml-standards-cheatsheet/</link>
		<comments>http://mark-kirby.co.uk/2009/xml-standards-cheatsheet/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 11:37:49 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=455</guid>
		<description><![CDATA[A simple guide to crafting standards compliant XML. Covers structuring XML documents, defining XML elements and how to best use attributes.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a simple guide to crafting standards compliant XML. I&#8217;m currently working on an API, and found it easy to knock off some XML for the output without thinking about it much. That&#8217;s not enough though, I wanted to follow some defined standards, so I did some research and decided to get the key points down here.</p>
<h2>Define XML</h2>
<p>XML is a way of marking up data. The data could be directly from a database, for example the result of a nested query. Instead of just outputting the results as plain text, we can mark up each element of the results in a machine readable format. That&#8217;s XML. </p>
<h2>Simple XML element</h2>
<p>A single element representing a stand alone piece of information would be represented as follows:</p>
<p>[code lang="xml"]</p>
<person>Mark</person>
[/code]</p>
<h2>Complex Types</h2>
<p>A name on its own might not be enough, for a person you might have other pieces of information. A person can be considered a complex type of XML element, constructed from several other XML elements.</p>
<p>[code lang="xml"]</p>
<person>
  <firstname>Mark</firstname><br />
  <surname>Kirby</surname></p>
<address>50 Poles Hill, Brighton, BN1</address>
</person>
[/code]</p>
<p>We could introduce another complex type to break up the address into further elements.</p>
<p>[code lang="xml"]</p>
<person>
  <firstname>Mark</firstname><br />
  <surname>Kirby</surname></p>
<address>
    <firstline>50 Poles Hill</firstline><br />
    <town>Brighton</town></p>
<postcode>BN1</postcode>
  </address>
</person>
[/code]</p>
<h2>Nested elements</h2>
<p>A root element (say, person) could have more than one of a specific element (say, phone number). This is fine, and would be represented as follows:</p>
<p>[code lang="xml"]</p>
<person>
  <firstname>Mark</firstname><br />
  <surname>Kirby</surname></p>
<phone>01273 4444441</phone>
<phone>07988 3838381</phone>
</person>
[/code]</p>
<h2>Attributes</h2>
<p>XML elements can have attributes added to them to add more information about the element. </p>
<p>I feel you should use attributes to add meta information about the element, information about the data itself, information useful to machines and not people. Here are a few examples:</p>
<ul>
<li>Database id&#8217;s</li>
<li>Created date</li>
<li>Edited date</li>
</ul>
<p>Here&#8217;s our person with some suitable attributes:</p>
<p>[code lang="xml"]</p>
<person id='1' created='21-01-2009' edited='22-01-2009'>
  <firstname>Mark</firstname><br />
  <surname>Kirby</surname>
</person>
[/code]</p>
<p>I&#8217;ve seen API&#8217;s come up with a single element (say person), and stuff the tag with attributes containing all the details, thus:</p>
<p>[code lang="xml"]</p>
<person firstname='Mark' surname='Kirby' address='50 Poles Hill...'></person>
[/code]</p>
<p>This is very bad! It&#8217;s hard to read, hard to process, inflexible and doesn&#8217;t follow established standards.</p>
<p>An attribute can only be used once per element, and you shouldn&#8217;t store multiple values for a single attribute.</p>
<p>This is wrong:</p>
<p>[code lang="xml"]</p>
<person tag='lawyer' tag='doctor'></person>
[/code]</p>
<p>This is wrong:</p>
<p>[code lang="xml"]</p>
<person tag='lawyer,doctor'></person>
[/code]</p>
<p>This is correct:</p>
<h2>Constructing an XML document</h2>
<p>An XML document should (and for should read must for standards sake) have the following features:</p>
<h3>An XML document should have the extension XML</h3>
<h3>An XML document should begin with the XML declaration</h3>
<p>[code lang="xml"]<br />
< ?xml version="1.0" encoding="Unicode" standalone="yes"?><br />
[/code]</p>
<ul>
<li>Version should be set to 1.0 to comply with the majority of parsers.</li>
<li>Encoding can be specified, or left out to assume Unicode</li>
<li>Standalone yes means there is no DTD or XSD document describing the XML available, no means there is a document, leave the attribute out to assume no</li>
</ul>
<h3>An XML document must have one and only one root element</h3>
<p>In the above example, if you wanted to list more than one person, you could start with a root element, &#8216;people&#8217;.</p>
<p>[code lang="xml"]</p>
<people>
<person>
        <firstname>Mark</firstname><br />
        <surname>Kirby</surname></p>
<address>50 Poles Hill, Brighton, BN1</address>
</person>
<person>
        <firstname>Chris</firstname><br />
        <surname>Kirby</surname></p>
<address>24 Linfield Road, Brighton, BN1</address>
</person>
</people>
[/code]</p>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2009/xml-standards-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PHPUnit with MAMP</title>
		<link>http://mark-kirby.co.uk/2009/installing-phpunit-with-mamp/</link>
		<comments>http://mark-kirby.co.uk/2009/installing-phpunit-with-mamp/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 12:10:59 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=433</guid>
		<description><![CDATA[Installing PHPUnit with MAMP - enabling unit testing within the MAMP environment]]></description>
			<content:encoded><![CDATA[<p>Download your preferred copy of PHPUnit from <a href="http://pear.phpunit.de/get/">http://pear.phpunit.de/get/</a></p>
<p>Extract the folder, placing the folder PHPUnit in /Applications/MAMP/bin/PHP5/lib/php</p>
<p>Open the file PHPUnit/Util/Fileloader.php and replace all instances of</p>
<pre>[code lang="php"]@php_bin@[/code]</pre>
<p>with</p>
<pre>[code lang="php"]/Applications/MAMP/bin/php5/bin/php[/code]</pre>
<p>Get the file pear-phpunit from the extracted folder and place it in usr/local/bin</p>
<ol>
<li> Open the finder</li>
<li>Select Go-&gt;to folder</li>
<li>enter usr/local/bin in the path</li>
<li>Drag and drop the file.</li>
</ol>
<p>With the finder open, select the file and open with a text editor. Ensure the file reads as follows:</p>
<pre>[code lang="php"]
#!/Applications/MAMP/bin/php5/bin/php
< ?php
/* PHPUnit
 *
 * Copyright (c) 2002-2008, Sebastian Bergmann <sb@sebastian-bergmann.de>.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   * Neither the name of Sebastian Bergmann nor the names of his
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * $Id: pear-phpunit 2805 2008-04-14 16:52:19Z sb $
 */

require_once 'PHPUnit/Util/Filter.php';

PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');

require 'PHPUnit/TextUI/Command.php';

define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');

PHPUnit_TextUI_Command::main();
?>
[/code]</pre>
<p>Now rename your file to phpunit (if you already have a copy of phpunit installed, rename the file to phpunit-mamp so you know which one to use). In terminal:</p>
<pre>[code lang="php"]
sudo mv /usr/local/bin/phpunit-pear /usr/local/bin/phpunit
[/code]</pre>
<p>Now you can run tests from within MAMP by simply typing phpunit into terminal.</p>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2009/installing-phpunit-with-mamp/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to use Zend Framework on Webfaction</title>
		<link>http://mark-kirby.co.uk/2009/how-to-use-zend-framework-on-webfaction/</link>
		<comments>http://mark-kirby.co.uk/2009/how-to-use-zend-framework-on-webfaction/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 14:46:34 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=429</guid>
		<description><![CDATA[A quick tutorial on setting up the Zend Framework on a Webfaction host. The problem I ran into was that Zend requires the domain point to the public subfolder, but Webfaction requires the domain point to the root of the application, otherwise the error &#8220;Not application mounted at the root of this domain&#8221; is shown.
Here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>A quick tutorial on setting up the Zend Framework on a Webfaction host. The problem I ran into was that Zend requires the domain point to the public subfolder, but Webfaction requires the domain point to the root of the application, otherwise the error &#8220;Not application mounted at the root of this domain&#8221; is shown.</p>
<p>Here&#8217;s how to avoid the issue.</p>
<ol>
<li>Create a regular Static/CGI/PHP application called &lt;appname&gt; within the panel</li>
<li>Place the Zend Framework code within the &lt;appname&gt; folder created inside &#8220;/home/&lt;username&gt;/webapps/&lt;appname&gt;&#8221;</li>
<li>Select the option in Panel for adding a new application</li>
<li>Select the &#8220;Symbolic link to static/cgi/php app&#8221; as app type</li>
<li>Name the app &lt;appname-symlink&gt;</li>
<li>In the extra info field add an absolute path to the public folder, such as &#8220;/home/&lt;username&gt;/webapps/&lt;appname&gt;/public&#8221;</li>
<li>Create a new website named &lt;appname-website&gt; (or whatever you like) which uses the application &lt;appnamesymlink&gt;</li>
<li>Create a domain and link it to the website &lt;appname-website&gt;</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2009/how-to-use-zend-framework-on-webfaction/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wordpress Slideshare code not working?</title>
		<link>http://mark-kirby.co.uk/2009/wordpress-slideshare-code-not-working/</link>
		<comments>http://mark-kirby.co.uk/2009/wordpress-slideshare-code-not-working/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 17:07:58 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=403</guid>
		<description><![CDATA[We found the SlideShare code for WordPress is no longer working out of the box. Its because there is one variable you need to add, the width. They used to add a default width of 425 in the code, this is now missing.
Therefore, make:
[code lang="bash"]
slideshare id=1068027&#038;doc=ribotmobiledesignuk
[/code]
[code lang="bash"]
slideshare id=1068027&#038;doc=ribotmobiledesignuk&#038;w=425
[/code]
]]></description>
			<content:encoded><![CDATA[<p>We found the SlideShare code for WordPress is no longer working out of the box. Its because there is one variable you need to add, the width. They used to add a default width of 425 in the code, this is now missing.</p>
<p>Therefore, make:</p>
<pre>[code lang="bash"]
slideshare id=1068027&#038;doc=ribotmobiledesignuk
[/code]</pre>
<pre>[code lang="bash"]
slideshare id=1068027&#038;doc=ribotmobiledesignuk&#038;w=425
[/code]</pre>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2009/wordpress-slideshare-code-not-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MIR (Malarkey Image Replacement) IE6 fix</title>
		<link>http://mark-kirby.co.uk/2008/mir-malarkey-image-replacement-ie6-fix/</link>
		<comments>http://mark-kirby.co.uk/2008/mir-malarkey-image-replacement-ie6-fix/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 09:51:24 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=375</guid>
		<description><![CDATA[I&#8217;ve been using the MIR technique for image replacement for a while now, but always have to use a fix for IE6. In IE6 the method causes the first letter of the text being replaced to be displayed. Since I keep searching my email for the fix which was sent to me by Jay Gooby, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using the <a href="http://www.stuffandnonsense.co.uk/archives/examples/malarkey-method-example.html">MIR technique</a> for image replacement for a while now, but always have to use a fix for IE6. In IE6 the method causes the first letter of the text being replaced to be displayed. Since I keep searching my email for the fix which was sent to me by <a href="http://gooby.org/">Jay Gooby</a>, I thought I&#8217;d post it on here.</p>
<pre>[code lang="css"]
.mir { letter-spacing : -1000em; text-indent : -999em; overflow : hidden; }
/* Just for Opera, but hide from MacIE */
/*\*/html&gt;body .mir { letter-spacing : normal; text-indent : -999em;
overflow : hidden;}
[/code]</pre>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2008/mir-malarkey-image-replacement-ie6-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to bulk delete bookmarks from delicious</title>
		<link>http://mark-kirby.co.uk/2008/how-to-bulk-delete-bookmarks-from-delicious/</link>
		<comments>http://mark-kirby.co.uk/2008/how-to-bulk-delete-bookmarks-from-delicious/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 21:03:22 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://mark-kirby.co.uk/?p=358</guid>
		<description><![CDATA[It can be hard to clean up your old bookmarks from your delicious account - if you have a large amount you want to get rid of, this provides a possible solution, although only for the more technical among you.]]></description>
			<content:encoded><![CDATA[<p>At work we recently decided to clean out most of the tags and a few old posts from the <a href="http://delicious.com/ribot">ribot delicious account</a>. I couldn&#8217;t find any nice tools that enabled this (if you know of one, do please let me know &#8211; this method is a bit of a hack). On the delicious site the only method is to manually delete each tag, when you have over 400 the four clicks it takes to do this just don&#8217;t make much sense.</p>
<p>The method I&#8217;m going to explain to you, in summary, is this:</p>
<ol>
<li>you will copy your bookmarks down to a local mySQL database using an existing open source tool</li>
<li>you will delete and edit them locally using your preferred tool</li>
<li>using a script I have made you will turn the database into an uploadable delicious export file</li>
<li>in your delicious account you will delete all your bookmarks and then import them again from the newly created, cleaned, file</li>
</ol>
<p>WARNING: this could go wrong, I accept no responsibility for any loss of data, read through before beginning and take a backup of all your bookmarks.</p>
<h2>Before you start</h2>
<ol>
<li>Ensure you have a local apache server with PHP and MySQL installed and enabled. On OS X you will simply need to <a href="http://mark-kirby.co.uk/2007/set-up-php-5-apache-2-and-mysql-5-on-os-x-leopard/">activate your installation</a>, on windows you can <a href="http://mark-kirby.co.uk/2008/how-to-create-a-local-copy-of-a-wordpress-site/">follow my instructions on installing WAMP</a><a href="http://mark-kirby.co.uk/2008/how-to-create-a-local-copy-of-a-wordpress-site/"><br />
</a></li>
<li>Locate a database editing tool, and it should be one that allows you to delete multiple rows at once such as <a href="http://www.navicat.com/">Navicat</a></li>
<li>Create a local database called &#8216;delicious&#8217;  and ensure there is a user that can access it &#8211; it could be the default user root if you haven&#8217;t changed anything since installing</li>
</ol>
<h2>Getting your bookmarks into the database</h2>
<p>Download the <a href="http://code.google.com/p/mysqlicious/downloads/list">mysqlicious tool</a></p>
<p>Unzip the downloaded file and open the mirror.php file</p>
<p>Find the first block of code and enter your database name (delicious) and the user and password as shown:</p>
<pre>[code lang="php"]
$MySQL_Host = "localhost";
$MySQL_Database = "delicious";
$MySQL_Table = "delicious";
$MySQL_Username = "root";
$MySQL_Password = "";
[/code]</pre>
<p>Then add your delicious username and password to the fields underneath. I found the tag option didn&#8217;t work for me, but the idea is you can restrict the export by tag.</p>
<p>Create a folder called delicious in the area where your webserver is set up to point to (this might be your Sites folder on OS X, instructions on the pages listed earlier).</p>
<p>Copy the two files, mirror.php and MySQLicious.php into this folder.</p>
<p>Go to <a href="http://localhost/delicious/mirror.php">http://localhost/delicious/mirror.php</a>, the tool should now export all your bookmarks to the database.</p>
<h2>Modify the database</h2>
<p>If you have a good tool, you can now go through the database table named delicious and quickly delete all the posts you no longer need.</p>
<p>A hint &#8211; by writing simple database queries you can easily boil your bookmarks down to certain tags &#8211; the following SQL will help you:</p>
<pre>[code lang="sql"]
select * from delicious where tags LIKE  '%ajax%' order by tags
[/code]</pre>
<h2>Delete all current bookmarks</h2>
<p>WARNING! This could go wrong &#8211; ensure you have <a href="https://secure.delicious.com/settings/bookmarks/export">exported the bookmarks to a file</a> as a backup first. Also please note that any bookmarks you import have to be all set to private, or all set to public &#8211; the previous public and private settings will be lost. This problem goes for any kind of import, either the method I am describing here, or by importing the exported file I just reminded you to save.</p>
<p>If you are ready, do the following to quickly delete all your bookmarks:</p>
<p>Go to your bookmarks and set the number displayed to 100</p>
<p>Copy and paste the following code into your browser address bar, replacing the site address</p>
<pre>[code lang="javascript"]
javascript:var delay=2;
var s=document.createElement('script'); s.type='text/javascript';
s.src='http://ghill.customer.netspace.net.au/re-mark/re-mark-del-code.js';
document.getElementsByTagName('head')[0].appendChild(s);
void(0);
[/code]</pre>
<p>(courtesy of Scripted Remark &#8211; <a href="http://ghill.customer.netspace.net.au/re-mark/index.html">Batch Editor For Bookmarks</a>)</p>
<p>Allow a few minutes for this to complete, then select the next button and repeat until all bookmarks are gone.</p>
<h2>Upload the bookmarks</h2>
<p>Download the <a href="http://mark-kirby.co.uk/wp-content/uploads/2008/12/delicious-import.php.zip">delicious-import.php</a> script I put together (right click on that link) and add it to the delicious folder. This file creates a bookmarks html file which can be imported into delicious, or any other browser.</p>
<p>Navigate to <a href="http://localhost/delicious/delicious-import.php">http://localhost/delicious/delicious-import.php</a>, save the outputted file somewhere, such as the Desktop (in Firefox go to File -&gt; Save Page As&#8230;) and make sure the extension is set to html.</p>
<p>Go to the <a href="https://secure.delicious.com/settings/bookmarks/import?manual=true">Manual import</a> settings and import the file you just saved.</p>
<p>Your done!</p>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2008/how-to-bulk-delete-bookmarks-from-delicious/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
