<?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>JonnyReeves.co.uk &#187; ActionScript 2</title>
	<atom:link href="http://www.jonnyreeves.co.uk/category/actionscript-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jonnyreeves.co.uk</link>
	<description>Actionscript, Flash, PHP and stuff</description>
	<lastBuildDate>Mon, 19 Jul 2010 15:36:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Logging in ActionScript 3</title>
		<link>http://www.jonnyreeves.co.uk/2010/02/logging-in-actionscript-3/</link>
		<comments>http://www.jonnyreeves.co.uk/2010/02/logging-in-actionscript-3/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 20:27:36 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=169</guid>
		<description><![CDATA[Logging is a fundamental part of any mid to large scale application, your application needs to be able to talk to other developers and Q&#038;A engineers to help diagnose problems and gain insight into what&#8217;s going on under the hood.  Jesse Warden recently wrote an excellent article on logging, however, my own implementation of [...]]]></description>
			<content:encoded><![CDATA[<p>Logging is a fundamental part of any mid to large scale application, your application needs to be able to talk to other developers and Q&#038;A engineers to help diagnose problems and gain insight into what&#8217;s going on under the hood.  Jesse Warden recently wrote <a href="http://jessewarden.com/2010/02/consulting-chronicles-3-preventing-fire-drills-crises-by-removing-land-mines-and-using-diagnostic-tools.html">an excellent article on logging</a>, however, my own implementation of logging AS3 apps differs so much that I thought it warranted a blog post.</p>
<h3>The Problems</h3>
<p>One of the most important things in OOP is to ensure that you avoid tight coupling; Jesse&#8217;s approach of using a static logger leaves your code scattered with a dependency on it.  </p>
<p>Another point that Jesse makes is how important it is to include the name of the enclosing class when writing a log message,</p>
<blockquote><p>&#8230; all log messages start with &#8220;ClassName::methodName&#8221; where ClassName is the name of the class you are in, and methodName is the current method the log message is in.  It seems a major pain at first, but I guarantee you when you start removing them 2 months later, you know EXACTLY where to find it vs. that one trace that stays there for weeks because no one found where the bastard is.
</p></blockquote>
<p>I couldn&#8217;t agree more with this, having come from working on a massive application with thousands of log messages, not knowing where a message was originating from would have been a nightmare.  However, Jesse&#8217;s approach is very manual and relies on your entire team being disciplined; not to mention the fact that as soon as you start refactoring that &#8220;ClassName::methodName&#8221; identifier is quickly going to get out of sync.</p>
<h3>A Commons Solution</h3>
<p>I feel that there is a simple solution to both the above problems in the form of the <a href="http://code.google.com/p/as3-commons/">AS3 Commons Logging Framework</a>.  The framework provides an abstraction of logging which means your code is not dependant on any one implementation, plus it has the added benefit of automatically adding the name of the Class when writing a log message; winner!</p>
<p>Usage is pretty straight forward, but requires a little more setup than Jesse&#8217;s static helper approach; first of all your request a static ILogger instance from the LoggerFactory at the top of your class and then you are free to use it throughout the Class to write log messages, for example:</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
package uk.<span class="me1">co</span>.<span class="me1">jonnyreeves</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">class</span> MyClass<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Request an ILogger instance for this Class.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw3">static</span> const LOGGER : ILogger = LogFactory.<span class="me1">getClassLogger</span><span class="br0">&#40;</span>MyClass<span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> MyClass<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Write a log message using the Logger instance.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LOGGER.<span class="me1">info</span><span class="br0">&#40;</span><span class="st0">&quot;Created instance of MyClass&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>Using the TraceLogger implementation which the AS3 Commons Logger will default to, you would receive the following in your <a href="http://yourpalmark.com/2005/07/01/trace-from-the-browser-using-standard-trace/">Flash TraceLog</a>:</p>
<pre>
Sun Feb 21 10:33:29 GMT+0000 2010 [INFO]  uk.co.jonnyreeves.MyClass - Created instance of MyClass
</pre>
<p>The beauty of this approach is that the actual implementation of the ILogger interface is left to the LoggerFactory which means it can be switched at runtime.  Another neat benfit is that the name of the Logger is taken from the encolosing Class which created it (via <a href="http://code.google.com/p/as3-commons/source/browse/tags/as3-commons-logging/1.1/src/main/actionscript/org/as3commons/logging/LoggerFactory.as">LoggerFactory.getClassLogger()</a>).  This mean that is you rename the Class as part of a refactoring effort, all the log messages contained in said class will automatically update.</p>
<h3>Getting More Specific</h3>
<p>So I&#8217;ve mentioned that your can decide the ILogger implementation at runtime, let&#8217;s see an example of that in action.  My current Logging implementation of choice is the excellent DeMonsters Monster Debugger which reminds me a lot of the AS2 classic, LumnicBox in that it allows you to fully inspect the Object Graph at run time.</p>
<p>The first thing we need is to create an implementation of LogFactory which will return our ILogger instances upon request:</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
package uk.<span class="me1">co</span>.<span class="me1">jonnyreeves</span>.<span class="me1">logging</span>.<span class="me1">util</span>.<span class="me1">monsterdebugger</span> <br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">import</span> nl.<span class="me1">demonsters</span>.<span class="me1">debugger</span>.<span class="me1">MonsterDebugger</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">import</span> org.<span class="me1">as3commons</span>.<span class="me1">logging</span>.<span class="me1">ILogger</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">import</span> org.<span class="me1">as3commons</span>.<span class="me1">logging</span>.<span class="me1">ILoggerFactory</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Provides a bridge between the AS3Commons Logging Framework and MonsterDebugger.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @author John Reeves<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">class</span> MonsterDebuggerLoggerFactory <span class="kw3">implements</span> ILoggerFactory <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Initialises MonsterDebugger<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param target&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; The Base Object you wisht to start graphing from (usually you will supply the<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Display Root DisplayObject).<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param clearConsole&nbsp; Clears MonsterDebugger&#8217;s Trace Console when the initial connection is made.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> MonsterDebuggerLoggerFactory<span class="br0">&#40;</span><span class="kw3">target</span> : <span class="kw3">Object</span>, clearConsole : <span class="kw3">Boolean</span> = <span class="kw2">true</span><span class="br0">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">new</span> MonsterDebugger<span class="br0">&#40;</span><span class="kw3">target</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>clearConsole<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MonsterDebugger.<span class="me1">clearTraces</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Factory Method, used to return an instance of ILogger to the AS3Commons Logging Framework.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> getLogger<span class="br0">&#40;</span><span class="kw3">name</span> : <span class="kw3">String</span><span class="br0">&#41;</span> : ILogger<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">new</span> MonsterDebuggerLogger<span class="br0">&#40;</span><span class="kw3">name</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>Now all that&#8217;s left to do is to create the MonsterDebuggerLogger implementation of the ILogger interface; this will re-write all the LOGGER.info(), etc calls through to MonsterDebugger.</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
package uk.co.jonnyreeves.logging.util.monsterdebugger <br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; import org.as3commons.logging.util.MessageUtil;<br />
&nbsp; &nbsp; &nbsp; &nbsp; import nl.demonsters.debugger.MonsterDebugger;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; import org.as3commons.logging.LogLevel;<br />
&nbsp; &nbsp; &nbsp; &nbsp; import org.as3commons.logging.impl.AbstractLogger;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; /**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Provides a bridge between the AS3 Commons Logging implementation and Monster Debugger; it&#8217;s not perfect but it <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* works for the most part.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The Target of the log message will always be the name of the logger.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The Object of the log message will vary depending on the parameters passed. &nbsp;If the message string is empty<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* then the params Array will be logged. &nbsp;If the message string is not empty, the params Array will be used to<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* tokenise the message string.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Usage:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; LOGGER.debug(&quot;Hello World&quot;);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Outputs message: &quot;(String) Hello World&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; LOGGER.debug(&quot;Hello {0} {1}, &quot;Jonny&quot;, &quot;Reeves&quot;);&nbsp; &nbsp; &nbsp; &nbsp; // Outputs message: &quot;(String) Hello Jonny Reeves&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; LOGGER.debug(&quot;&quot;, [ 1, 2, 3 ]);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Outputs message: &quot;(Array)&#8230;&quot; (which can then be inspected)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Incorrect usage:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; LOGGER.debug(&quot;Some Array&quot;, [1, 2, 3]);&nbsp; // Outputs message: &quot;(String) Some Array&quot; (which can&#8217;t be inspected)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @author John Reeves<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/<br />
&nbsp; &nbsp; &nbsp; &nbsp; public class MonsterDebuggerLogger extends AbstractLogger <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public var level : int = LogLevel.DEBUG;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public function MonsterDebuggerLogger(name : String) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; super(name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override protected function log(level : uint, message : String, params : Array) : void<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (level &gt;= this.level)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var target : Object = name;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var object : Object = getLogObject(message, params);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var colour : uint = getLogMessageColour(level);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MonsterDebugger.trace(target, object, colour);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function getLogObject(message : String, params : Array) : Object <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (message == &quot;&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // If the user only supplied a single param to log, we remove the params array which is enclosing it.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (params.length == 1) ? params.pop() : params;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return MessageUtil.toString(message, params);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function getLogMessageColour(level : int) : uint <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var colour : int;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (level)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case LogLevel.FATAL:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case LogLevel.ERROR:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colour = MonsterDebugger.COLOR_ERROR;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case LogLevel.WARN:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colour = MonsterDebugger.COLOR_WARNING;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colour = MonsterDebugger.COLOR_NORMAL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return colour;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override public function get debugEnabled() : Boolean<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return LogLevel.DEBUG &gt;= level;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override public function get errorEnabled() : Boolean<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return LogLevel.ERROR &gt;= level;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override public function get infoEnabled() : Boolean<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return LogLevel.INFO &gt;= level;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override public function get warnEnabled() : Boolean<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return LogLevel.WARN &gt;= level;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; override public function get fatalEnabled() : Boolean<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return LogLevel.FATAL &gt;= level;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
&nbsp;</div>
<p>The code here is fairly self documenting with the protected log() method proxying all the logging requests through to MonsterDebugger.  Because the creators of the AS3Commons Logging Project specified the message param to have a datatype of String, we are forced to do a little bit of a workaround when we want to dump Objects out to the MonsterDebugger console.  There is an <a href="http://code.google.com/p/as3-commons/issues/detail?id=3">open ticket</a> on the AS3Commons project page should you wish to request a change.</p>
<p>The last piece of the puzzle is to swap the AS3Commons LoggingFactory implementation, this is very straight forward and requires a single line of code during your application&#8217;s startup routine (preferably before any logging takes place).</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
package &nbsp;<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">import</span> uk.<span class="me1">co</span>.<span class="me1">jonnyreeves</span>.<span class="me1">logging</span>.<span class="me1">util</span>.<span class="me1">MonsterDebuggerLoggerFactory</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="me1">Sprite</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Application Entry Point.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @author John Reeves<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">class</span> MyApp <span class="kw3">extends</span> Sprite <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> MyApp<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LoggerFactory.<span class="me1">loggerFactory</span> = <span class="kw2">new</span> MonsterDebuggerLoggerFactory<span class="br0">&#40;</span><span class="kw3">this</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>Once this is done you are free to start using the LoggingFactory as per the example further up the page.  Your log messages should now show up in the MonsterDebugger logging console.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2010/02/logging-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Automatically Generating a Maven POM file with ANT</title>
		<link>http://www.jonnyreeves.co.uk/2010/01/automatically-generating-a-maven-pom-file-with-ant/</link>
		<comments>http://www.jonnyreeves.co.uk/2010/01/automatically-generating-a-maven-pom-file-with-ant/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 18:20:34 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=151</guid>
		<description><![CDATA[This one tripped me up for a while and doesn&#8217;t seem to be mentioned in the Maven ANT Tasks Documentation.  I was working on a build process which makes use of Maven soley for deploying and versioning releases and ANT for the rest of the build.  One thing I wanted to eliminate was [...]]]></description>
			<content:encoded><![CDATA[<p>This one tripped me up for a while and doesn&#8217;t seem to be mentioned in the <a href="http://maven.apache.org/ant-tasks/reference.html">Maven ANT Tasks Documentation</a>.  I was working on a build process which makes use of Maven soley for deploying and versioning releases and ANT for the rest of the build.  One thing I wanted to eliminate was the large amount of POM files which were scattered around the project, all of which were basically the same and could most certainly be auto-generated.</p>
<p>The Maven ANT Tasks <a href="http://maven.apache.org/ant-tasks/examples/write-pom.html">indicate that the &lt;pom /&gt; task can be used to create an &#8220;in-memory&#8221; pom</a> which can then be used in the &lt;deploy /&gt; task.  With that in mind, I wrote the following:</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="sc3"><span class="re1">&lt;artifact:pom</span> <span class="re0">id</span>=<span class="st0">&quot;maven.project&quot;</span> <span class="re0">groupId</span>=<span class="st0">&quot;com.example&quot;</span> <span class="re0">version</span>=<span class="st0">&quot;${build.version}&quot;</span> <span class="re0">artifactId</span>=<span class="st0">&quot;${project.name}&quot;</span> <span class="re0">packaging</span>=<span class="st0">&quot;zip&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;remoteRepository</span> <span class="re0">id</span>=<span class="st0">&quot;releases&quot;</span> <span class="re0">url</span>=<span class="st0">&quot;http://maven:8081/nexus/content/repositories/releases&quot;</span> <span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;/artifact:pom<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;artifact:install-provider</span> <span class="re0">artifactId</span>=<span class="st0">&quot;wagon-http-lightweight&quot;</span> <span class="re0">version</span>=<span class="st0">&quot;1.0-beta-2&quot;</span> <span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;artifact:deploy</span> <span class="re0">file</span>=<span class="st0">&quot;deploy/${project.name}.zip&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;pom</span> <span class="re0">refid</span>=<span class="st0">&quot;maven.project&quot;</span> <span class="re2">/&gt;</span></span> <br />
<span class="sc3"><span class="re1">&lt;/artifact:deploy<span class="re2">&gt;</span></span></span><br />
&nbsp;</div>
<p>However, when this ran, the build failed with the following error: &#8220;<strong>A distributionManagement element or remoteRepository element is required to deploy</strong>&#8220;.  Very confusing, especially as I specified the &lt;remoteRepository /&gt; node as a child of the &lt;pom /&gt;.  I concluded that this was not a problem with the &lt;deploy /&gt; task as when I dump the contents of &#8220;maven.pom&#8221; out to disk via &lt;writepom /&gt; I could see that, sure enough, the &lt;repositories /&gt; node was not being created in the POM file!  This is where I hit a brick wall and I can only presume it&#8217;s a bug with the current Maven ANT Tasks (2.1.0).</p>
<p>With that in mind, I tried modifying the &lt;deploy /&gt; task, adding the &lt;remoteRepository /&gt; node to that instead &#8211; again, no joy, same error.</p>
<p>In the end I got it to work with a little bit of a workaround involving temp files &#8211; this works fine for me but it&#8217;s not ideal, hopefully someone out there has encountered this one before:</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="sc3"><span class="coMULTI">&lt;!&#8211; &nbsp;Generate a Dynamic POM file &#8211;&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;artifact:pom</span> <span class="re0">id</span>=<span class="st0">&quot;pom.tmp.ref&quot;</span> <span class="re0">groupId</span>=<span class="st0">&quot;com.example&quot;</span> <span class="re0">version</span>=<span class="st0">&quot;${build.version}&quot;</span> <span class="re0">artifactId</span>=<span class="st0">&quot;${project.name}&quot;</span> <span class="re0">packaging</span>=<span class="st0">&quot;zip&quot;</span> <span class="re2">/&gt;</span></span></p>
<p><span class="sc3"><span class="coMULTI">&lt;!&#8211; &nbsp;Write the generated POM file out to a temporary file on disc &#8211;&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;tempfile</span> <span class="re0">property</span>=<span class="st0">&quot;pom.tmp.file&quot;</span> <span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;artifact:writepom</span> <span class="re0">pomRefId</span>=<span class="st0">&quot;pom.tmp.ref&quot;</span> <span class="re0">file</span>=<span class="st0">&quot;${pom.tmp.file}&quot;</span> <span class="re2">/&gt;</span></span></p>
<p><span class="sc3"><span class="coMULTI">&lt;!&#8211; &nbsp;Read the temporary file back in as the POM reference &#8211;&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;artifact:pom</span> <span class="re0">id</span>=<span class="st0">&quot;maven.project&quot;</span> <span class="re0">file</span>=<span class="st0">&quot;${pom.tmp.file}&quot;</span> <span class="re2">/&gt;</span></span></p>
<p><span class="sc3"><span class="coMULTI">&lt;!&#8211; We can now deploy, but we have to include a reference to the repository &#8211;&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;artifact:install-provider</span> <span class="re0">artifactId</span>=<span class="st0">&quot;wagon-http-lightweight&quot;</span> <span class="re0">version</span>=<span class="st0">&quot;1.0-beta-2&quot;</span> <span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;artifact:deploy</span> <span class="re0">file</span>=<span class="st0">&quot;deploy/${project.name}.zip&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;pom</span> <span class="re0">refid</span>=<span class="st0">&quot;maven.project&quot;</span> <span class="re2">/&gt;</span></span> <br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;remoteRepository</span> <span class="re0">id</span>=<span class="st0">&quot;releases&quot;</span> <span class="re0">url</span>=<span class="st0">&quot;http://maven:8081/nexus/content/repositories/releases&quot;</span> <span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;/artifact:deploy<span class="re2">&gt;</span></span></span><br />
&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2010/01/automatically-generating-a-maven-pom-file-with-ant/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash on the Beach 2008 &#8211; Tuesday Write Up</title>
		<link>http://www.jonnyreeves.co.uk/2008/10/flash-on-the-beach-2008-tuesday-write-up/</link>
		<comments>http://www.jonnyreeves.co.uk/2008/10/flash-on-the-beach-2008-tuesday-write-up/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 10:34:24 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[fotb]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=61</guid>
		<description><![CDATA[I went down to the Flash on the Beach 08 conference yesterday, here&#8217;s some of the notes that I wrote up on the train back:
Creating The Next Generation Happy Meal Toy
Julain Dolce
Julian is lead Developer for Fuel Industies, a creative agency that worked on a large scale campaign for the fast food chain McDonalds.  [...]]]></description>
			<content:encoded><![CDATA[<p>I went down to the <a href="http://flashonthebeach.com/">Flash on the Beach</a> 08 conference yesterday, here&#8217;s some of the notes that I wrote up on the train back:</p>
<h2><strong>Creating The Next Generation Happy Meal Toy</strong></h2>
<p><em>Julain Dolce</em></p>
<p>Julian is lead Developer for <a href="http://www.fuelindustries.com/">Fuel Industies</a>, a creative agency that worked on a large scale campaign for the fast food chain McDonalds.  The project was a rich multimedia experience centred on <a href="http://www.fuelindustries.com/casestudies/fairiesanddragons/">magical fairies and dragons</a>.  The application was delivered on CD which was bundled with Happy Meals.  The campaign proved very successful pushing over 80 million units in 30 countries.  He began his presentation with a brief overview of the product (marred somewhat by the fact the projector was not playing ball and he had to show it to the audience from the screen of his 15” Macbook).</p>
<p>Julian&#8217;s project had several key requirements which were taken into consideration during the initial planning stage:</p>
<ul>
<li> App. must be Cross Platform (Win32 and Mac OS)</li>
<li> Installed from a CD, with no internet access required</li>
<li> Handle multiple windows (for performance) and alpha transparency</li>
</ul>
<p>This ruled out Adobe Air 1.0 as it can&#8217;t be installed solely from a CD, it also has issues with full frame transparency.  As a result they settled on a mixture of <a href="http://www.multidmedia.com/software/zinc/">MDM Zinc 3</a> and <a href="http://www.screentime.com/software/mprojector/">mProjector</a>.  They also used <a href="http://bitrock.com/products_installbuilder_overview.html">Install Builder</a>, which is a Cross Platform (Win32, Linux and Mac) installation creator.  Their main Flash tools were FDT and Eclipse, they made use of SVN and constructed a couple of custom tools in C# using <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation">WPF on Win32</a></p>
<p>Julian’s team ended up building most of their application in ActionScript 2, Julain cited this was because of a lack of a mature ActionScript 3 development environment when the project was started in the summer of 2007.  They used SVN to keep code versioned, Mantis to track bugs and took advantage of an automated build process to get the builds out to testers.  They also kept Excel spreadsheets for each library asset which detailed file locations, settings (offsets, alpha, and compression ratios for all Cell animations, sounds and linkageid&#8217;s, etc.</p>
<p>The team made use of JSFL, which can be used to create custom scripts inside Adobe CS Applications &#8211; one such example was the ability to apply an affect to the selected symbols in the Document&#8217;s Library.</p>
<p>Their major testing problem was performance bound &#8211; using fullscreen alpha transparency bought things to a crawl and meant click events went unnoticed on slower machines &#8211; as a result they split the animations down into separate transparent windows which moved across the stage (the user’s desktop).  They used LocalConnection calls to get these panels to talk to each other and sync up.</p>
<p>Although the project appeared to go smoothly and was obviously successful, Julian did admit to one major failing.  In the time between sending the CD&#8217;s off for pressing in China and the returned product &#8211; Mac OS X 10.5 shipped &#8211; and unfortunately, their application did not work on it &#8211; whoops.</p>
<h2>Adobe Town Hall Meeting</h2>
<p><em>Richard Galvan, Mike Downey, Paul Betlem, Lee Brimelow and Matt Millar.</em></p>
<p>The second talk of the day consisted of 5 members of the Adobe Team &#8211; 3 platform evangelists and two Flash Player engineers.  The group asked questions asked by the audience.  I managed to ask a question in the session:</p>
<p>&#8220;The company I work for are currently porting a large scale AS2 project to AS3 and were disheartened by the lack of support and tools made available by Adobe to assist in this.  By using the Proxy class we have managed to create shims for most the intrinsic AS2 classes, but I Would like to know why Adobe did not do this and release it to the community.&#8221;</p>
<p>Their reply wasn’t what I was hoping for (but was to be expected).  I was told that Actionscript 3 was designed to target new customers and that they wanted to add as many features as possible to the language. I’m not quite sure what to infer from this seeing as AS2 obviously had a massive user base.  The group did, however, acknowledge that the lack of community support in the transition from AS2 to AS3 was a problem (although, again, made no indication that any tools would be forthcoming) .  They rounded off my question by assuring that ASVM1 Content (AS1 and 2 SWFs) would continue to be usable in Flash Player releases in the future.</p>
<p>Another interesting question that was asked was about the support for Dynamic Runtime Languages to script the published flash applications and allow greater control at runtime.  The team responded by saying that a new project &#8211; FLACC (FLAsh C++) is in the works which will allows C++ code to run natively inside the Flash Player. This could lead to other language interpreters being made available and will prove a very powerful tool for ActionScript developers.</p>
<p>Adobe also confirmed that Flash 10 is being worked on for the iPhone &#8211; but Apple has not confirmed it will be approved.  Flash Player 10 will include the new unloadAndStop() method to help with Garbage Collection when unloading external content in the Player and that there is no AS4 on the cards &#8211; instead they will work on improving AS3 whilst pushing ECMAScript 4 forwards (they hinted that Private Constructors might be coming back)</p>
<p>After the Session I spoke to an Adobe Flash Player engineer, Matt Millar.  I told him about our Library Linkage Problem where Child Objects placed on the stage in frame 2 (or greater) are not linked to the Display Chain on the first tick.  Whilst I was asking this question, another developer stepped in and claimed it was a major problem for his team.  I gave Matt my business card and the told me he would be in touch &#8211; I&#8217;m hoping that this will be fixed before FP 10 is released, but I am not holding my breath!</p>
<h2>Grant Skinner</h2>
<p><em>Things every ActionScript developer should know.</em></p>
<p>Grant is a well revered programmer in the ActionScript community, <a href="http://gskinner.com/blog/">his Blog</a> provides an excellent resource and he heads up his own <a href="http://gskinner.com/site2_5/">development team</a>.  Grant&#8217;s talk was aimed at developers of all skill levels, but focused mainly on the grass roots.  Grant gave an interesting presentation which, in his words, he wished someone had given to him 5 years ago &#8211; I&#8217;m not sure I can agree it was as life changing as Grant made out &#8211; but that may be in part due to the best practices which Mind Candy&#8217;s dev team strives towards ;)</p>
<p>Grant started off by assuring the audience that were no right answers in programming &#8211; don’t be driven to fake absolutes, although there are no definitive right answers there are plenty of wrong ones!  Code is art, Grant stressed, learn the rules before you can start to break them and don’t get hooked on Design Patterns – they’re not the answer to everything.</p>
<p>Grant then proceeded to lay down some programming fundamentals &#8211; Enforce code standards as it makes inheriting files easier.  Think of code like <a href="http://en.wikipedia.org/wiki/Lego">Lego</a>, not <a href="http://en.wikipedia.org/wiki/Play-Doh">Playdoh</a>.  If you are building a space ship in Playdoh and want to change the engine you have to pull it all apart &#8211; with Lego you can take apart and reassemble with ease &#8211; your code should be like this too.  Code flows down in specialisation &#8211; at the very top of the Object stack is the Main Application Controller which includes very specific logic for this one particular app &#8211; however as you move outwards, objects should become more generic and reusable.  When working with reusable code, remember inside looking out &#8211; prefer composition and event dispatching over tight coupling and inheritance.</p>
<p>Grant also recommended the use of Service delegates to act as a layer between Server Side logic and Controller Logic in Flash, that way, the server side logic can change with only the one class needing modification on the Flash side.</p>
<p>Moving towards Flash Player specifics, Grant told the audience to always keep learning &#8211; read every API you can &#8211; you don&#8217;t have to specialise but at least know what FP10 is capable of.  Also remember that AS3 needs you to be very particular about Garbage Collection &#8211; always create destructors in your AS3 objects to handle this in one place.</p>
<p>Grant bought up the concept of using Timeline based Event dispatching.  His example was a simple graphical dialogue box (like we use in Moshi), where the box just dispatches events when it finished tweening in / out &#8211; that way Classes using this Timeline code / Library Linage just need to register for its events removing any form of tight coupling.  Grant proceeded to talk about he makes use of JSFL to create custom Panels and &#8220;Graphical Objects&#8221;  &#8211; a single click from the command line laid out all the frames, labels and AS3 timeline code for creating a Graphical Button (including the Linkage name!)</p>
<p>Finally, Grant reminded the audience that we are blessed to have the Flash IDE &#8211; we can create prototype and concepts in seconds &#8211; get out there an experiment!</p>
<p>You can view Grant&#8217;s <a href="http://gskinner.com/talks/thingseveryflash/">slides for his presentation</a> over on his site &#8211; note that you will need <a href="http://labs.adobe.com/downloads/flashplayer10.html">Flash Player 10 beta</a> installed as he makes use of the new 3D features present</p>
<h2>Platform Jujitsu</h2>
<p><em>Lee Brimelow</em></p>
<p>Lee (who runs <a href="http://theflashblog.com/">theflashblog.com</a>) came back in the afternoon to evangelise about the new CS4 platform, showing us some of the new features available across the entire product line (Flash CS4, Flex Builder 4 and Flash Player 10).  He started off his speech by outlining that Flash Developers much be proficient in 5 main areas:</p>
<ul>
<li> Motion and Video</li>
<li> Visual Design (using Photoshop and Illustrator)</li>
<li> Object Orientated ActionScript</li>
<li> Flash and Flash IDE&#8217;s</li>
<li> Server Side Integration</li>
</ul>
<p>With the introduction out of the way, Lee went on to talk about some of the new features in Flash Player 10.  First up was native 3D &#8211; this provides full antialiased 3D inside with AS3, and, as it&#8217;s intrinsic to the player, it&#8217;s very fast!  Lee stressed that this was meant to compliment, not replace more mature and capable 3D engines like PaperVision (but mentioned that there were plenty of new API&#8217;s that those guys would be hooking in to to speed things up).  To accompany this, the drawing API has received an overhaul to allow drawing and manipulating programmatically generated 3D Objects</p>
<p>Next up was Adobe&#8217;s Advanced Text Engine &#8211; this is in the form of an AS3 API which Lee described as bewildering to anyone except &#8220;Text Nerds&#8221; &#8211; he said it provided an incredible amount of control &#8211; so much so that they were planning to release a CS4 component shortly after release which would allow &#8220;normal people&#8221; to harness it&#8217;s power &#8211; he did however say that this component would not ship with CS4.</p>
<p>Flash Player 10 will incorporate a host of &#8220;tweaks&#8221; including true Hardware Acceleration which will improve the speed of Video and Bitmap Manipulation (Filters, Pixel Bender operations).  Local file access will be included (but will require user prompts), the previously mentioned unloadAndStop() method will be added and the new <a href="http://www.mikechambers.com/blog/2008/08/19/using-vectors-in-actionscript-3-and-flash-player-10/">Vector datatype</a> for strongly typed Arrays.</p>
<p>One of the new features that Lee was getting excited about was <a href="http://www.kaourantin.net/2008/05/adobe-pixel-bender-in-flash-player-10.html">Pixel Bender</a> &#8211; this allows image processing with shaders and filters and looked very interesting.  Lee showed a custom demo where he <a href="http://theflashblog.com/?p=386">created his own filter</a> in HLSL (High Level Shader Language &#8211; which looked a bit like C#).  One of the most exciting things about Pixel Bender is the fact that it is threaded separately from Flash Player &#8211; Lee said that complex calculations could be passed off to the Pixel Bener to allow for Mutli Threading in Flash Applications &#8211; if this is true, and it&#8217;s as easy as Lee hinted then this will be a major break through for Flash Player and will be immensely useful for <a href="http://www.moshimonsters.com/">complex Flash Apps</a>.</p>
<p>Lee proceeded to talk about Adobe Air 1.5 and Flex Builder 4, neither of which sounded very exciting &#8211; alough Flex 4 will feature (yet another) XML based language for handling graphics in Flex.</p>
<p>Finally, Lee showed us some of the features of the new Flash CS4 IDE including live previews of 3d Images.  The Flash Properties Panel now includes a new Z property alongside the traditional x and y which allows you to move symbols in space (away from the camera) &#8211; he whipped up a simple, live demonstration of this which was very impressive, however, he insisted the really cold 3D features would only be available via AS3 scripting.  He wrapped up his Flash CS4 presentation by mentioning that the Flash IDE ActionScript Panel had not been touched in this release &#8211; in his own words &#8211; fail.</p>
<h2>The Best 8 to 12 Hours of My Life</h2>
<p><em>Robert Hodgin</em></p>
<p>The day ended with a visual presentation by <a href="http://www.flight404.com/">Robert Hodgin</a> who specialises in Audio Visualisation code &#8211; whilst not ActionScript based, his visuals provided some inspiring ideas and concepts along with a recommendation that the audience branch out and try a hit of &#8216;cid if they haven&#8217;t had the privilege.</p>
<p><a href="http://www.flight404.com/_videos/magnetosphere/index.html">Magneto Visulisation of Trentemoller&#8217;s Miss You</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2008/10/flash-on-the-beach-2008-tuesday-write-up/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Typesafe Enums in ActionScript 2</title>
		<link>http://www.jonnyreeves.co.uk/2008/07/typesafe-enums-in-actionscript-2/</link>
		<comments>http://www.jonnyreeves.co.uk/2008/07/typesafe-enums-in-actionscript-2/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 09:24:07 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as2]]></category>
		<category><![CDATA[enum]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[oo]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=59</guid>
		<description><![CDATA[Typesafe Enums are perfect when you want to get the message across loud and clear, with no room for error.  The classic use for an Enum is handling events, to give some context I&#8217;ll demonstrate how you could handle events without using an Enum:

/**
&#160;* This example method will send an event back to a [...]]]></description>
			<content:encoded><![CDATA[<p>Typesafe <a href="http://en.wikipedia.org/wiki/Enumerated_type">Enums</a> are perfect when you want to get the message across loud and clear, with no room for error.  The classic use for an Enum is handling events, to give some context I&#8217;ll demonstrate how you could handle events without using an Enum:</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="coMULTI">/**<br />
&nbsp;* This example method will send an event back to a Registered Listener, in this<br />
&nbsp;* case we&#8217;re going to inform the listener that we have loaded our data and <br />
&nbsp;* are ready for use.<br />
&nbsp;*<br />
&nbsp;* &nbsp; &nbsp; &nbsp;@param Void<br />
&nbsp;* &nbsp; &nbsp; &nbsp;@return Void<br />
*/</span><br />
<span class="kw3">private</span> <span class="kw2">function</span> __onLoadComplete<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// This forms the basis of the event we are going to send.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> eventObject:<span class="kw3">Object</span> = <span class="kw2">new</span> <span class="kw3">Object</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Populate our eventObject with its type &amp; the event message to send</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="kw3">type</span> = <span class="st0">&#8216;ModelEvent&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="me1">event</span> = <span class="st0">&#8216;data_loaded&#8217;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// And send the object via mx.events.EventDispatcher</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">dispatchEvent</span><span class="br0">&#40;</span>eventObject<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>The listener object (in this case, a Controller), will then have a similar method for handling callbacks, again, without using an enum we would be left to switch on a string, something like this:</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="coMULTI">/**<br />
&nbsp;* Example function, showing us registering the event listener to the Model with<br />
&nbsp;* a delegated callback to the __onModelEvent() function.<br />
&nbsp;*<br />
&nbsp;*&nbsp; &nbsp; &nbsp; @param Void<br />
&nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
*/</span><br />
<span class="kw3">private</span> <span class="kw2">function</span> registerModel<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; model.<span class="me1">addEventListener</span><span class="br0">&#40;</span><span class="st0">&quot;modelEvent&quot;</span>, Delegate.<span class="me1">create</span><span class="br0">&#40;</span><span class="kw3">this</span>, __onModelEvent<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p>
<span class="coMULTI">/**<br />
&nbsp;* Callback method which was registered at the same time as adding the eventListener<br />
&nbsp;* this method handles incoming events from registered models<br />
&nbsp;*<br />
&nbsp;*&nbsp; &nbsp; &nbsp; @param Object event object dispatched from registered model.<br />
&nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
*/</span><br />
<span class="kw3">private</span> <span class="kw2">function</span> __onModelEvent<span class="br0">&#40;</span>event:<span class="kw3">Object</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">switch</span> <span class="br0">&#40;</span>event.<span class="me1">event</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;data_loaded&#8217;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span> <span class="br0">&#40;</span><span class="st0">&#8216;Controller::__onModelEvent &#8212; Data Loaded!&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">default</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span> <span class="br0">&#40;</span><span class="st0">&#8216;Controller::__onModelEvent &#8212; Unkown Model State recieved: &#8216;</span> + event.<span class="me1">event</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>Obviously this approach works, but it can lead to some quite obvious, yet tricky to find errors.   For example, what if I set the value of eventObject.state to &#8216;Data_Loaded&#8217;, or mashed the keyboard and entered &#8216;data_laoded&#8217;?  Of course, both these problems can be spotted (the trace() on default will help you debug typos, and a `event.state.toLowerCase()` would help with the first problem, but what about when other people are working with the code &#8211; how will they be able to tell which states are available to them, this is especially true if there are multiple listeners to modelEvents, maybe all the state&#8217;s aren&#8217;t show in each switch() &#8211; now we&#8217;re starting to see the bigger issue &#8211; one of software design.  Wouldn&#8217;t it be great if we could bring all the Model State messages into one place?</p>
<p>Say hello to the ModelEvent Enum Class:</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="coMULTI">/**<br />
&nbsp;* ModelEvent.as<br />
&nbsp;* John Reeves, http://www.jonnyreeves.co.uk/<br />
&nbsp;* May 2008<br />
&nbsp;*<br />
&nbsp;* Typesafe Event dispatched from Models.<br />
*/</span><br />
<span class="kw2">class</span> ModelEvent<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">var</span> <span class="kw3">_name</span>:<span class="kw3">String</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">var</span> _level:<span class="kw3">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Private Constructor for creating ModelEvent instances. &nbsp;This stops developers<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; * creating their own ModelEvent&#8217;s in the code, instead we encourage people<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* to create Static Model Events below:<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> ModelEvent<span class="br0">&#40;</span><span class="kw3">name</span>:<span class="kw3">String</span>, <span class="kw3">level</span>:<span class="kw3">Number</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="kw3">_name</span> = <span class="kw3">name</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>._level = <span class="kw3">level</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Static Events Models can Send.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">var</span> DATA_LOADED:ModelEvent = <span class="kw2">new</span> ModelEvent<span class="br0">&#40;</span><span class="st0">&#8216;DATA_LOADED&#8217;</span>, <span class="nu0">1</span><span class="br0">&#41;</span>;&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">var</span> DATA_ERROR:ModelEvent = <span class="kw2">new</span> ModelEvent<span class="br0">&#40;</span><span class="st0">&#8216;DATA_ERROR&#8217;</span>, <span class="nu0">2</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; </p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns the ModelEvent object for the given ModelEvent String<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param mediaType the MediaType&#8217;s name<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return the MediaType object<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span>&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw3">static</span> <span class="kw2">function</span> forName<span class="br0">&#40;</span>ModelEvent:<span class="kw3">String</span><span class="br0">&#41;</span>:ModelEvent<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>ModelEvent<span class="br0">&#91;</span>ModelEvent.<span class="kw3">toUpperCase</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#93;</span> <span class="kw3">instanceof</span> ModelEvent<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> ModelEvent<span class="br0">&#91;</span>ModelEvent.<span class="kw3">toUpperCase</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; </p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns the current ModelEvent&#8217;s name as a String<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> getName<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw3">this</span>.<span class="kw3">_name</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; </p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns the current ModelEvent&#8217;s Level as a Number<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> getLevel<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">Number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw3">this</span>._level;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Compares an incoming ModelEvent (x) to the current Object.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param ModelEvent x Incoming ModelEvent Object to perform comparison on.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Boolean true if it matches<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> equals<span class="br0">&#40;</span>x:ModelEvent<span class="br0">&#41;</span>:<span class="kw3">Boolean</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>x.<span class="me1">getName</span><span class="br0">&#40;</span><span class="br0">&#41;</span> == <span class="kw3">this</span>.<span class="me1">getName</span><span class="br0">&#40;</span><span class="br0">&#41;</span> &amp;&amp; x.<span class="me1">getLevel</span><span class="br0">&#40;</span><span class="br0">&#41;</span> == <span class="kw3">this</span>.<span class="me1">getLevel</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>&nbsp; &nbsp; &nbsp; &nbsp;<br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>This class is used a little differently to most others.  As the constructor is set to private, we don&#8217;t expect developers to be creating instances of ModelEvent&#8217;s in their own code (so in the case of the Model&#8217;s __onLoadComplete() function which was shown above, we wouldn&#8217;t other developers using the new keyword to create their own instance of ModelEvent).  Instead, we expect developers to access the pre-defined ModelStates via the <strong>static</strong> public properties defined inside the class, let&#8217;s show a quick example and revisit our Model&#8217;s onLoadComplete method:</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="coMULTI">/**<br />
&nbsp;* Now we will update this method to use the ModelEvent Enum class.<br />
&nbsp;*<br />
&nbsp;* &nbsp; &nbsp; &nbsp;@param Void<br />
&nbsp;* &nbsp; &nbsp; &nbsp;@return Void<br />
*/</span><br />
<span class="kw3">private</span> <span class="kw2">function</span> __onLoadComplete<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// This forms the basis of the event we are going to send.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> eventObject:<span class="kw3">Object</span> = <span class="kw2">new</span> <span class="kw3">Object</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Populate our eventObject with its type &amp; the state message to send, </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// this time instead of setting state as a String, we set it to be on the </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// ModelEvent&#8217;s static properties.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="kw3">type</span> = <span class="st0">&#8216;ModelEvent&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="me1">event</span> = ModelEvent.<span class="me1">DATA_LOADED</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// And send the object via mx.events.EventDispatcher</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">dispatchEvent</span><span class="br0">&#40;</span>eventObject<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>That was straight forward &#8211; an now we don&#8217;t have to worry about typo&#8217;s or mixing the case, any mistakes at this point will be caught by the Compiler when you build the swf.  Okay, that&#8217;s cool, but how do we handle recieving the events in the Controller?  Even easier!</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="coMULTI">/**<br />
&nbsp;* Callback method, this time update to handle the incoming ModelEvent<br />
&nbsp;*<br />
&nbsp;*&nbsp; &nbsp; &nbsp; @param Object event object dispatched from registered model.<br />
&nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
*/</span><br />
<span class="kw3">private</span> <span class="kw2">function</span> __onModelEvent<span class="br0">&#40;</span>event:<span class="kw3">Object</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// extract the ModelEvent Enum from the event Object</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> event:ModelEvent = event.<span class="me1">event</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Use the ModelEvent::equals method to perform comparison</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>event.<span class="me1">equals</span><span class="br0">&#40;</span>ModelEvent.<span class="me1">DATA_LOADED</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span> <span class="br0">&#40;</span><span class="st0">&#8216;Controller::__onModelEvent &#8212; Data Loaded!&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>Of course, if you prefer you could switch based on event.getLevel() with the case statements performing comparisons on ModelEvent.DATA_LOADED.getLevel();</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2008/07/typesafe-enums-in-actionscript-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CNET TV Videos</title>
		<link>http://www.jonnyreeves.co.uk/2008/07/cnet-tv-videos/</link>
		<comments>http://www.jonnyreeves.co.uk/2008/07/cnet-tv-videos/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 08:45:07 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=58</guid>
		<description><![CDATA[I&#8217;ve recently been slaving away on Version 4 of the CNET Video Player.  Today is the official launch of the new player and it would appear everything has gone smoothly.  The player features numerous enhancements over the previous version including a full XSPF playlist, XML Configuration, Support for related content at the end [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been slaving away on Version 4 of the <a href="http://videos.cnet.co.uk/">CNET Video Player</a>.  Today is the official launch of the new player and it would appear everything has gone smoothly.  The player features numerous enhancements over the previous version including a full <a href="http://xspf.org">XSPF playlist</a>, XML Configuration, Support for related content at the end of playback and off site embedding (with full metrics).</p>
<p><center><br />
<!-- Start CNET Embed Player -->
<div style="width: 400px; overflow: hidden;"><object type="application/x-shockwave-flash" data="http://www.cnet.co.uk/embed/39039360" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="400" height="265" allowfullscreen="true"><param name="allowScriptAccess" value="always"/><param name="movie" value="http://www.cnet.co.uk/embed/39039360"/><param name="loop" value="false"/><param name="allowFullScreen" value="true"/><param name="quality" value="high"/><param name="bgcolor" value="#dddddd" /></object>
<div style="width: 400px; height: 26px; background-color: #dddddd; overflow: hidden;">
<ul style="text-align: left; margin: 5px 0; padding: 2px; font-size: 10px; font-family: arial; color: #999;">
<li style="list-style: none; float: left; margin-right: 5px;"><a href="http://videos.cnet.co.uk/39039360.htm" style="color: #fff; display: inline;">Sony Ericsson W760i</a></li>
<li style="list-style: none; float: left; margin-right: 5px;"><strong>|</strong></li>
<li style="list-style: none; float: left;"><a href="http://videos.cnet.co.uk/" style="color: #fff; display: inline;">More videos from CNET.co.uk</a></li>
</ul>
</div>
</div>
<p><!-- Finish CNET Embed Player --><br />
</center></p>
<p>I will try and give a more detailed write up of some of the component features at a later date, but for now it&#8217;s back to work rolling out the rest of the enhancements to the video page!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2008/07/cnet-tv-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript &#8211; Loading Acute and UTF-8 Characters from XML into Dynamic Text with Flash</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/actionscript-acute-utf-8-data-xml-flash/</link>
		<comments>http://www.jonnyreeves.co.uk/2008/06/actionscript-acute-utf-8-data-xml-flash/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 09:17:32 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[acute]]></category>
		<category><![CDATA[dynamic text]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=54</guid>
		<description><![CDATA[Writing flexible applications in Flash is easy, (/me points in the direction of my XML Configuration Class) and there&#8217;s few reasons why all your text strings should not be read in at run time to allow for easy internationalization.
However, one pitfall to be aware of is trying to use Acutes and other &#8220;non-latin&#8221; characters in [...]]]></description>
			<content:encoded><![CDATA[<p>Writing flexible applications in Flash is easy, (/me points in the direction of my <a href="http://www.jonnyreeves.co.uk/2008/06/actionscript-20-configuration-class/">XML Configuration Class</a>) and there&#8217;s few reasons why all your text strings should not be read in at run time to allow for easy internationalization.</p>
<p>However, one pitfall to be aware of is trying to use Acutes and other &#8220;non-latin&#8221; characters in dynamic text fields (é, etc).  I was having a problem when these characters were not only not showing up, but all characters after the acute were being truncated!  Here&#8217;s my configuration XML:</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;UTF-8&quot;</span> <span class="re2">?&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;configuration<span class="re2">&gt;</span></span></span><br />
&nbsp;<span class="sc3"><span class="re1">&lt;textValue<span class="re2">&gt;</span></span></span>armén<span class="sc3"><span class="re1">&lt;/textValue<span class="re2">&gt;</span></span></span><br />
&nbsp;<span class="sc3"><span class="re1">&lt;/configuration<span class="re2">&gt;</span></span></span><br />
&nbsp;</div>
<p><em>Side Note: Flash Player 9 appears to ignore the <a href="http://www.w3schools.com/XML/xml_encoding.asp">XML Encoding</a> value specified in XML files, however it&#8217;s good practice to adhere to web standards, so make sure your XML&#8217;s encoding is set to UTF-8</em></p>
<p>The next obvious set is to ensure that you embedding all the required glyphs in your .fla file, you do this by clicking on the <em>Embed&#8230;</em> button for your Dynamic Textfield &#8211; make sure you embed all the Latin characters you need and then specify the acutes and other UTF-8 characters seperatley in the &#8220;include these characters:&#8221; textbox:</p>
<p><img src="http://www.jonnyreeves.co.uk/wp-content/uploads/2008/06/flash-character-embedding.gif" alt="The Character Embedding Dialouge in Flash CS3" title="flash-character-embedding" width="500" height="283" class="aligncenter size-full wp-image-55" /></p>
<p>Now this is where the problem comes in &#8211; when I try to compile and run this flash movie, instead of getting the text <em>armén</em> in my textfield, I get <em>arm</em> with both the acute (é) and any trailing characters truncated (in some cases (as in the screen shot below), I even get some of the trailing XML&#8230; eek!)</p>
<p><img src="http://www.jonnyreeves.co.uk/wp-content/uploads/2008/06/utf-8-dynamic-text-error1.jpg" alt="The UTF-8 Text String \&quot;armén\&quot; is breaking the layout" title="utf-8-dynamic-text-error1" width="442" height="334" class="aligncenter size-full wp-image-57" /></p>
<p>After a bit of head scratching I finally managed to track down the problem: The XML file must be saved as UTF-8 encoding!  (d&#8217;oh!)  However, in tracking down the problem I also discovered another workaround using <a href="http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary723.html">System.useCodepage</a>.  Setting this value to &#8216;true&#8217; in the first frame of your actionscript will force flash to ignore the character encoding of the XML document.</p>
<p>Hope this saves someone some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2008/06/actionscript-acute-utf-8-data-xml-flash/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ActionScript 2.0 Configuration Class</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/actionscript-20-configuration-class/</link>
		<comments>http://www.jonnyreeves.co.uk/2008/06/actionscript-20-configuration-class/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 13:19:27 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[flashvar]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=38</guid>
		<description><![CDATA[This is an update to my original Actionscript 2.0 Configuration Class which I wrote back in February.  It features a new access method for reading and writing values and allows you to load in external XML configuration documents with an easy to understand Schema.  All comments welcome.

This class allows simple loading of Configuration [...]]]></description>
			<content:encoded><![CDATA[<p>This is an update to my original <a href="http://www.jonnyreeves.co.uk/2008/02/actionscript-20-configuration-class-readwrite/">Actionscript 2.0 Configuration Class</a> which I wrote back in February.  It features a new access method for reading and writing values and allows you to load in external XML configuration documents with an easy to understand Schema.  All comments welcome.<br />
<span id="more-38"></span><br />
This class allows simple loading of Configuration values into your ActionScript 2.0 Flash application &#8211; you can either defined your values in an external XML file (which is easy to read and edit &#8211; even by XML novices) or by using flashVars attached to the root of the stage.</p>
<p>Once you have loaded in your configuration values you can easily access or alter them by using the static method Configure.read(&#8217;key&#8217;) or Configure.write(&#8217;key&#8217;, &#8216;value&#8217;).</p>
<p>This class follows the <a href="http://en.wikipedia.org/wiki/Singleton_pattern">Singleton Design Pattern</a> (or <a href="http://en.wikipedia.org/wiki/Anti-pattern">Anti-Pattern</a> depending on what side of the fence you sit on) &#8211; what this means, in a nutshell is that you can access the values stored in the Configuration from anywhere in your code &#8211; it also means that if you update the values using Configure.write() they will be updated globally.</p>
<p>You can <a href="http://www.jonnyreeves.co.uk/wp-content/uploads/2008/06/jonnyreeeves_configure.zip">download a .zip file of the Class</a> complete with a detailed example of how to use it in your application.</p>
<p>Any questions &#8211; feel free to post in the comments below.</p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="kw3">import</span> mx.<span class="me1">events</span>.<span class="me1">EventDispatcher</span>;<br />
<span class="kw3">import</span> mx.<span class="me1">utils</span>.<span class="me1">Delegate</span>; </p>
<p><span class="coMULTI">/**<br />
&nbsp;* ActionScript 2.0 Configuration Class<br />
&nbsp;* John Reves, http://www.jonnyreeves.co.uk/<br />
&nbsp;* June 2008<br />
&nbsp;*<br />
&nbsp;* Singleton configuration class with class notation value access and XML<br />
&nbsp;* import.<br />
*/</span><br />
<span class="kw2">class</span> co.<span class="me1">uk</span>.<span class="me1">jonnyreeves</span>.<span class="me1">Configure</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Event Listener</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">var</span> dispatchEvent:<span class="kw2">Function</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">var</span> addEventListener:<span class="kw2">Function</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">var</span> removeEventListener:<span class="kw2">Function</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Singleton Instance of this Object.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw3">static</span> <span class="kw2">var</span> _INSTANCE:Configure;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Dynamic Object containing all configuration values<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @see Configure::read()<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">var</span> _values:<span class="kw3">Object</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Interval used to handle Timeouts when retrieving XML Documents.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">var</span> _xmlTimeoutInterval:<span class="kw3">Number</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Indicates if the XML document timed out whilst loading.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">var</span> _hasTimedOut:<span class="kw3">Boolean</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Constructor<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Private, Access via getInstance() only.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> Configure<span class="br0">&#40;</span><span class="kw3">Void</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>._values = <span class="kw2">new</span> <span class="kw3">Object</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EventDispatcher.<span class="me1">initialize</span><span class="br0">&#40;</span><span class="kw3">this</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Return a singleton instance of Configure.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Configure instance<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">function</span> getInstance<span class="br0">&#40;</span><span class="kw3">Void</span><span class="br0">&#41;</span>:Configure<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>_INSTANCE == <span class="kw3">undefined</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _INSTANCE = <span class="kw2">new</span> Configure<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> _INSTANCE;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Attempts to load in Configuration from an XML File, will dispatch<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* an Event depending on the result of this method.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param xmlFile Location of XML File containing Configuration Values<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">function</span> loadXML<span class="br0">&#40;</span>xmlFile:<span class="kw3">String</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> _this:Configure = getInstance<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> parser:<span class="kw3">XML</span> = <span class="kw2">new</span> <span class="kw3">XML</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parser.<span class="kw3">ignoreWhite</span> = <span class="kw2">true</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Handles XML Document Retreval.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parser.<span class="kw3">onLoad</span> = <span class="kw2">function</span><span class="br0">&#40;</span>success:<span class="kw3">Boolean</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>success &amp;amp;&amp;amp; _this.__validates<span class="br0">&#40;</span><span class="kw3">this</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _this.__clearXMLTimeout<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _this.__parseXML<span class="br0">&#40;</span><span class="kw3">this</span>.<span class="kw3">childNodes</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>, _this._values<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _this.__onXMLLoadSuccess<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _this.__onXMLLoadError<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Create an Interval to handle timeouts.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _this.__createXMLTimeout<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parser.<span class="kw3">load</span><span class="br0">&#40;</span>xmlFile<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Attemps to load all flashVars from _root which exist in the &#8216;config&#8217;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* namespace. &nbsp;flashVars should be written using dot notation, but with<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* underscores replacing the dots.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* For example:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; _root.config_testMessage = &#8216;hello world!&#8217;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; _root.config_shapes_rectangle_width&#8217; = &#8216;250&#8242;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Or using SWFObject notation in the HTML<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; fo.AddVariable(&#8217;config_testMessage&#8217;, &#8216;hello world!&#8217;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; fo.AddVariable(&#8217;config_shapes_rectangle_width&#8217;, &#8216;250&#8242;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">function</span> loadFlashVars<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> flashVar:<span class="kw3">String</span> <span class="kw1">in</span> <span class="kw3">_root</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>flashVar.<span class="kw3">substr</span><span class="br0">&#40;</span><span class="nu0">0</span>, <span class="nu0">7</span><span class="br0">&#41;</span> == <span class="st0">&#8216;config_&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Configure.<span class="me1">write</span><span class="br0">&#40;</span>flashVar.<span class="kw3">substr</span><span class="br0">&#40;</span><span class="nu0">7</span><span class="br0">&#41;</span>.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">&#8216;_&#8217;</span><span class="br0">&#41;</span>.<span class="kw3">join</span><span class="br0">&#40;</span><span class="st0">&#8216;.&#8217;</span><span class="br0">&#41;</span>, <span class="kw3">unescape</span><span class="br0">&#40;</span><span class="kw3">_root</span><span class="br0">&#91;</span>flashVar<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Read a Variable from the Loaded Configuration. &nbsp;Access to Conifg Groups<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* is handled in {dot} notation. &nbsp;So to access _config[Omniture][tracking][dc]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* you would pass in the String &#8216;omniture.tracking.dc&#8217;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param key Variable to obtain in . notation<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return String value of Configure::_values[key]<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">function</span> read<span class="br0">&#40;</span><span class="kw3">key</span>:<span class="kw3">String</span><span class="br0">&#41;</span>:<span class="kw3">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Turn the . syntax notation into AS2.0 Array access notation.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> keys:<span class="kw3">Array</span> = <span class="kw3">key</span>.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">&#8216;.&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> thisGroup:<span class="kw3">Object</span> = getInstance<span class="br0">&#40;</span><span class="br0">&#41;</span>._values<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span>keys.<span class="kw3">length</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thisGroup = thisGroup<span class="br0">&#91;</span>keys.<span class="me1">shift</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Debugging.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>thisGroup.<span class="kw3">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span> == <span class="kw3">undefined</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span><span class="br0">&#40;</span><span class="st0">&#8216;Configure::read &#8211; Returning Undefined Value for: &#8216;</span> + <span class="kw3">arguments</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> thisGroup.<span class="kw3">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Write a Key, Value pair to the Config Object at Run Time. &nbsp;The key<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* should be supplied in {dot} notation. &nbsp;The return value could slow<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* down performance on writes.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param key Varible to write in . notation<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param value Value to write to @param key as a String<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return indicates write was succesfull.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">function</span> write<span class="br0">&#40;</span><span class="kw3">key</span>:<span class="kw3">String</span>, value:<span class="kw3">String</span><span class="br0">&#41;</span>:<span class="kw3">Boolean</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Helper method used for recursion</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getInstance<span class="br0">&#40;</span><span class="br0">&#41;</span>.__recurseWrite<span class="br0">&#40;</span><span class="kw3">key</span>.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">&#8216;.&#8217;</span><span class="br0">&#41;</span>, value, getInstance<span class="br0">&#40;</span><span class="br0">&#41;</span>._values<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span>read<span class="br0">&#40;</span><span class="kw3">key</span><span class="br0">&#41;</span> == value<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Helper method used by Configure::write() when dealing with &quot;deep&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* values inside the _values object. &nbsp;Method will recurse through the<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* input String (x), and write value to the current configObj node.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param keys Array contianing the &quot;path&quot; of _values object to write to<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param value String value to write to ConfigObject.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param configObj Current Node of the Configuration Values _values object<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> __recurseWrite<span class="br0">&#40;</span>keys:<span class="kw3">Array</span>, value:<span class="kw3">String</span>, configObj:<span class="kw3">Object</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Write if that was the last key index.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>keys.<span class="kw3">length</span> == <span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; configObj<span class="br0">&#91;</span>keys.<span class="me1">shift</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#93;</span> = value;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Otherwise Recurse again, create new object if needed.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> thisKey = keys.<span class="me1">shift</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>configObj<span class="br0">&#91;</span>thisKey<span class="br0">&#93;</span> == <span class="kw3">undefined</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; configObj<span class="br0">&#91;</span>thisKey<span class="br0">&#93;</span> = <span class="kw2">new</span> <span class="kw3">Object</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.__recurseWrite<span class="br0">&#40;</span>keys, value, configObj<span class="br0">&#91;</span>thisKey<span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Callback to handle failed attempts to Load the configuration XML.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> __onXMLLoadError<span class="br0">&#40;</span><span class="kw3">Void</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.__clearXMLTimeout<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> eventObject:<span class="kw3">Object</span> = <span class="kw2">new</span> <span class="kw3">Object</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="kw3">target</span> = <span class="kw3">this</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="kw3">type</span> = <span class="st0">&#8216;configureEvent&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="kw3">name</span> = <span class="st0">&#8216;Configure.onXMLLoadError&#8217;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">dispatchEvent</span><span class="br0">&#40;</span>eventObject<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* XML has been successfully loaded and is ready to be interacted with.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> __onXMLLoadSuccess<span class="br0">&#40;</span><span class="kw3">Void</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> eventObject:<span class="kw3">Object</span> = <span class="kw2">new</span> <span class="kw3">Object</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="kw3">target</span> = <span class="kw3">this</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="kw3">type</span> = <span class="st0">&#8216;configureEvent&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eventObject.<span class="kw3">name</span> = <span class="st0">&#8216;Configure.onXMLLoaded&#8217;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.<span class="me1">dispatchEvent</span><span class="br0">&#40;</span>eventObject<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Validates the loaded XML Document<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param xml XMLObject loaded by Configure::loadXML()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Boolean false on validation errors<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> __validates<span class="br0">&#40;</span><span class="kw3">xml</span>:<span class="kw3">XML</span><span class="br0">&#41;</span>:<span class="kw3">Boolean</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Abort if we have already timed out.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">this</span>._hasTimedOut<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span> <span class="br0">&#40;</span><span class="st0">&#8216;Configure::__validateXML &#8211; Refusing to Parse XML, timed out&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Check the first node is </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">String</span><span class="br0">&#40;</span><span class="kw3">xml</span>.<span class="kw3">childNodes</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="kw3">nodeName</span><span class="br0">&#41;</span> !== <span class="st0">&quot;configuration&quot;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.__onInvalidXML<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Parses the Loaded XML Documents, populating this object&#8217;s _values prop.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param xml XMLObject loaded by Configure::loadXML()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param config Internal Configuration Object to write values to<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> __parseXML<span class="br0">&#40;</span><span class="kw3">xml</span>:<span class="kw3">XMLNode</span>, config:<span class="kw3">Object</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// loop through all Children of this Node.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> nodeCount:<span class="kw3">Number</span> = <span class="kw3">xml</span>.<span class="kw3">childNodes</span>.<span class="kw3">length</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i:<span class="kw3">Number</span> = <span class="nu0">0</span>; i &lt; nodeCount; i++<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> thisNode:<span class="kw3">XMLNode</span> = <span class="kw3">xml</span>.<span class="kw3">childNodes</span><span class="br0">&#91;</span>i<span class="br0">&#93;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Recurse into Config Groups (tricky because values are considered to have Length.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>thisNode.<span class="kw3">childNodes</span>.<span class="kw3">length</span> &gt; <span class="nu0">0</span> &amp;amp;&amp;amp; thisNode.<span class="kw3">childNodes</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="kw3">nodeValue</span> == <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Create new Object off of this._values</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; config<span class="br0">&#91;</span>thisNode.<span class="kw3">nodeName</span><span class="br0">&#93;</span> = <span class="kw2">new</span> <span class="kw3">Object</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.__parseXML<span class="br0">&#40;</span>thisNode, config<span class="br0">&#91;</span>thisNode.<span class="kw3">nodeName</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Write Value</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; config<span class="br0">&#91;</span>thisNode.<span class="kw3">nodeName</span><span class="br0">&#93;</span> = thisNode.<span class="kw3">childNodes</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="kw3">nodeValue</span>.<span class="kw3">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Creates an Interval used by Configure::loadXML to handle XML documents<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* which timeout.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> __createXMLTimeout<span class="br0">&#40;</span><span class="kw3">Void</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>._xmlTimeoutInterval = <span class="kw2">_global</span>.<span class="me1">setTimeout</span><span class="br0">&#40;</span><span class="kw3">this</span>, <span class="st0">&#8216;__onXMLTimeout&#8217;</span>, <span class="nu0">1000</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>._hasTimedOut = <span class="kw2">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Triggered when the timeout in createXMLTimeout() has expired, indicates<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* that the XML document failed to load.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> __onXMLTimeout<span class="br0">&#40;</span><span class="kw3">Void</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span> <span class="br0">&#40;</span><span class="st0">&#8216;Configure::__onXMLTimeout&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>._hasTimedOut = <span class="kw2">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.__clearXMLTimeout<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>.__onXMLLoadError<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Gets called when the Parser fails to parse the incoming configuration<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* XML.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @return Void<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> __onInvalidXML<span class="br0">&#40;</span><span class="kw3">Void</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span><span class="br0">&#40;</span><span class="st0">&#8216;Configure::__onInvalidXML&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Clears the Interval, tidies up.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> __clearXMLTimeout<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">clearInterval</span><span class="br0">&#40;</span><span class="kw3">this</span>._xmlTimeoutInterval<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2008/06/actionscript-20-configuration-class/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flare &#8211; Actionscript 2.0 SWF Decompiler</title>
		<link>http://www.jonnyreeves.co.uk/2008/02/flare-actionscript-20-swf-decompiler/</link>
		<comments>http://www.jonnyreeves.co.uk/2008/02/flare-actionscript-20-swf-decompiler/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 10:15:07 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=27</guid>
		<description><![CDATA[Flare is a free (as in beer) Actionscript 2.0 decompiler with GUI clients for Windows and Mac (and CLI for Windows, Mac and Linux).  I just had a quick play with it to examine a 3rd party component (swc file) and was suprised by the readability of the output; running it on my on .swf [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.nowrap.de/flare.html">Flare</a> is a free (as in beer) Actionscript 2.0 decompiler with GUI clients for Windows and Mac (and CLI for Windows, Mac and Linux).  I just had a quick play with it to examine a 3rd party component (swc file) and was suprised by the readability of the output; running it on my on .swf made me realise that decompilation was a trivial task.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2008/02/flare-actionscript-20-swf-decompiler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript 2.0 Configuration Class (read/write)</title>
		<link>http://www.jonnyreeves.co.uk/2008/02/actionscript-20-configuration-class-readwrite/</link>
		<comments>http://www.jonnyreeves.co.uk/2008/02/actionscript-20-configuration-class-readwrite/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 21:54:18 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=25</guid>
		<description><![CDATA[@Update &#8211; Please note that this post is considered deprecated &#8211; please refer to: http://www.jonnyreeves.co.uk/2008/06/actionscript-20-configuration-class/
I like all of my apps to be as flexible as possible; as a result I tend to make nearly every aspect configurable.  There are quite a few approaches to Configuring your Flash app, with many programmers settling for putting [...]]]></description>
			<content:encoded><![CDATA[<p><strong>@Update &#8211; Please note that this post is considered deprecated &#8211; please refer to: <a href="http://www.jonnyreeves.co.uk/2008/06/actionscript-20-configuration-class/">http://www.jonnyreeves.co.uk/2008/06/actionscript-20-configuration-class/</a></strong></p>
<p>I like all of my apps to be as flexible as possible; as a result I tend to make nearly every aspect configurable.  There are quite a few approaches to Configuring your Flash app, with many programmers settling for putting _root variables on the first frame of the .fla file.  Sure, this works, but it does not enable script type checking at run-time and it also means that you can&#8217;t feed values in as flashVars.</p>
<p>To combat these problems, I created a simple Configuration base class and a Factory method which allows you to access it as a singleton:<span id="more-25"></span></p>
<h3>Config (Singleton) Class</h3>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="coMULTI">/**<br />
&nbsp;* Config.as<br />
&nbsp;* John Reeves (www.jonnyreeves.co.uk)<br />
&nbsp;*<br />
&nbsp;* Actionscript 2.0 Singleton Configuration Class. &nbsp;This class will load<br />
&nbsp;* specified config and then allow you to read/write from it at run-time.<br />
*/</span><br />
<span class="kw3">import</span> BaseConfig;<br />
<span class="kw2">class</span> Config<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @var _instance<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Instance of config, created only by load() method.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">var</span> _instance:Config;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Private constructor, as this class is a Singleton we don&#8217;t<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* want instances to be be created outside of the Factory<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* method (load()).<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">function</span> Config<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Factory method for loading the desired configuration instance.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Extend this method out if you intend to have multiple<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Configurations accessible at compile time.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param config&nbsp; &nbsp;Configuration you wish to load.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">load</span><span class="br0">&#40;</span>config:<span class="kw3">String</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Check if configuration has already loaded.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>_configuration !== <span class="kw3">undefined</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">throw</span> <span class="kw2">new</span> <span class="kw3">Error</span><span class="br0">&#40;</span><span class="st0">&#8216;Config::load() -&gt; Configuration&#8217;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +<span class="st0">&#8216; has already been loaded.&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">switch</span> <span class="br0">&#40;</span>config.<span class="kw3">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;base&#8217;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _configuration = <span class="kw2">new</span> BaseConfig<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">default</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">throw</span> <span class="kw2">new</span> <span class="kw3">Error</span><span class="br0">&#40;</span><span class="st0">&#8216;Config::load() -&gt; Invalid&#8217;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + <span class="st0">&#8216; configuration requested&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Read a configuration value from the loaded instance.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param key&nbsp; &nbsp; &nbsp; Property you wish to read from loaded instance.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">function</span> read<span class="br0">&#40;</span><span class="kw3">key</span>:<span class="kw3">String</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Check user has loaded a config.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>_configuration == <span class="kw3">undefined</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">throw</span> <span class="kw2">new</span> <span class="kw3">Error</span><span class="br0">&#40;</span><span class="st0">&#8216;Config::read() -&gt; No configuration&#8217;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +<span class="st0">&#8216; loaded, please Config.load() one first.&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Using the Array access method.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> _configuration<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Write to the currently loaded configuration instance.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param key&nbsp; &nbsp; &nbsp; Property you wish to write<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; @param value&nbsp; &nbsp; New value for above Property<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">static</span> <span class="kw3">public</span> <span class="kw2">function</span> write<span class="br0">&#40;</span><span class="kw3">key</span>:<span class="kw3">String</span>, value:<span class="kw3">Object</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>_configuration == <span class="kw3">undefined</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">throw</span> <span class="kw2">new</span> <span class="kw3">Error</span><span class="br0">&#40;</span><span class="st0">&#8216;Config::read() -&gt; No configuration&#8217;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +<span class="st0">&#8216; loaded, please use Config.load() first.&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Only write values if the property exists in the Config&#8217;s </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Constructor, this is a nasty ActionScript 2.0 hack.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>_configuration.<span class="me1">hasOwnProperty</span><span class="br0">&#40;</span><span class="st0">&quot;_&quot;</span> + <span class="kw3">key</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Using array access method, will call custom setter.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _configuration<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span> = value;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Refusing to write key, add any error handling here.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span> <span class="br0">&#40;</span><span class="st0">&#8216;Config.write() -&gt; Invalid Property: &#8216;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +<span class="kw3">key</span>.<span class="kw3">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<h3>Example Configuration Class (set your values here)</h3>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="coMULTI">/**<br />
&nbsp;* BaseConfiguration.as<br />
&nbsp;* John Reeves (www.jonnyreeves.co.uk)<br />
&nbsp;*<br />
&nbsp;* Base configuration class, should you need even more flexibility<br />
&nbsp;* at run-time you can extend this and add to the Factory Method in<br />
&nbsp;* the Config class.<br />
&nbsp;*<br />
&nbsp;* This file contains the actual configuration values for your application<br />
&nbsp;* complete with Strict Type Checking at both Compile and Run time.<br />
*/</span><br />
<span class="kw2">class</span> BaseConfiguration<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @var _exampleProtectedString<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* This is an example string which has a default value but can&#8217;t be<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* over-ridden at run time with a flashVar. (see Constructor)<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;protected <span class="kw2">var</span> _exampleProtectedString:<span class="kw3">String</span> = <span class="st0">&#8216;default value&#8217;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @var _exampleString<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* This is an example string, it doesn&#8217;t have a default value but<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* can be over-ridden at run time with a flashVar. &nbsp;(see Constructor)<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">var</span> _exampleString:<span class="kw3">String</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @var _exampleNumber<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* private var _examplePrivateNumber<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* This is an example number, it has a default value and can be<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* over-ridden by a flashVar at runtime.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">private</span> <span class="kw2">var</span> _exampleNumber:<span class="kw3">Number</span> = <span class="nu0">1234</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Constructor<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Any properties defined here can be over-ridden at run-time by flashVars<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* embedded in the HTML. &nbsp;Any properties not defined will be &quot;protected&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> BaseConfiguration<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// These props are modifiy-able at runtime with flashVars.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exampleString = <span class="kw3">this</span>._exampleString;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exampleNumber = <span class="kw3">this</span>._exampleNumber;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// If the next line were un-commented, we would be able to</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// modify exampleProtectedString at runtime with a flashVar</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// exampleProtectedString = this._exampleProtectedString;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Getter and Setter for exampleString<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">get</span> exampleString<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw3">this</span>._exampleString;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">set</span> exampleString<span class="br0">&#40;</span>value:<span class="kw3">String</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Run time type checking.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>value !== <span class="kw3">undefined</span> || value !== <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>._exampleString = value.<span class="kw3">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Getter and Setter for exampleProtectedString<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">get</span> exampleProtectedString<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw3">this</span>._exampleProtectedString;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">set</span> exampleProtectedString<span class="br0">&#40;</span>value:<span class="kw3">String</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Run time type checking.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>value !== <span class="kw3">undefined</span> || value !== <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>._exampleString = value.<span class="kw3">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Getter and Setter for exampleNumber<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">get</span> exampleNumber<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">Number</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw3">this</span>._exampleNumber;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">set</span> exampleNumber<span class="br0">&#40;</span>value:<span class="kw3">Number</span><span class="br0">&#41;</span>:<span class="kw3">Void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Run time type checking.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>!<span class="kw3">isNaN</span><span class="br0">&#40;</span>value<span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">this</span>._exampleNumber = <span class="kw3">Number</span><span class="br0">&#40;</span>value<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<h3>Example Script which Reads and Writes from the Config</h3>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;">
<span class="coMULTI">/**<br />
&nbsp;* Main.as<br />
&nbsp;* John Reeves (www.jonnyreeves.co.uk)<br />
&nbsp;*<br />
&nbsp;* Example application which will use our Config class to read a value<br />
&nbsp;* and write any flashVars which were passed in at run time.<br />
&nbsp;*<br />
&nbsp;* Please note that this is psudo code and probably wont&#8217; compile.<br />
*/</span><br />
<span class="kw3">import</span> Config;<br />
<span class="kw2">class</span> Main<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Constructor, just an example of using the config class.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> Main<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Load &#8216;base&#8217; config</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Config.<span class="kw3">load</span><span class="br0">&#40;</span><span class="st0">&#8216;base&#8217;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Trace out exampleString</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span><span class="br0">&#40;</span>Config.<span class="me1">read</span><span class="br0">&#40;</span><span class="st0">&#8216;exampleNumber&#8217;</span><span class="br0">&#41;</span>;&nbsp; &nbsp; &nbsp;<span class="co1">// outputs &quot;1234&quot;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Set an example flashVar (_root), this can also be done</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// in the HTML using the flashVar param, or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// using the URI param: move=&quot;main.swf?exampleNumber=4321&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">_root</span>.<span class="me1">exampleNumber</span> = <span class="nu0">4321</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Load in all flashVars from the _root and set them</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> flashVar <span class="kw1">in</span> <span class="kw3">_root</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Loop each _root var and set it in our config</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Config.<span class="me1">write</span><span class="br0">&#40;</span>flashVar, <span class="kw3">unescape</span><span class="br0">&#40;</span><span class="kw3">_root</span><span class="br0">&#91;</span>flashVar<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span> <span class="br0">&#40;</span>Config.<span class="me1">read</span><span class="br0">&#40;</span><span class="st0">&#8216;exampleNumber&#8217;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;&nbsp; &nbsp;<span class="co1">// outputs &quot;4321&quot;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// And with a string (outputs &quot;default Value&quot;)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span> <span class="br0">&#40;</span>Config.<span class="me1">read</span><span class="br0">&#40;</span><span class="st0">&#8216;exampleProtectedString&#8217;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// try to over-write a &quot;protected&quot; value (one not set in the</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// BaseConfiguration constructor.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">_root</span>.<span class="me1">exampleProtectedString</span> = <span class="st0">&quot;a new value&quot;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Load in all flashVars from _root again&#8230;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> flashVar <span class="kw1">in</span> <span class="kw3">_root</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Loop each _root var and set it in our config</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Config.<span class="me1">write</span><span class="br0">&#40;</span>flashVar, <span class="kw3">unescape</span><span class="br0">&#40;</span><span class="kw3">_root</span><span class="br0">&#91;</span>flashVar<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// as it&#8217;s protected, it won&#8217;t have written it</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">trace</span> <span class="br0">&#40;</span>Config.<span class="me1">read</span><span class="br0">&#40;</span><span class="st0">&#8216;exampleProtectedString&#8217;</span><span class="br0">&#41;</span> <span class="co1">// still outputs</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// &quot;default value&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>So, as I hope you can see, usage is pretty straight forward, and as the Config class is a singleton, and the read() and write() methods are both static, they can be accessed from anywhere in your code (as long as you import Config.as)</p>
<p>Download all 3 .as files above: <a href="http://www.jonnyreeves.co.uk/wp-content/uploads/2008/02/jonnyreeves_config_class_as2.zip" title="Actionscript 2.0 Configuration Class .zip">Actionscript 2.0 Configuration Class .zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2008/02/actionscript-20-configuration-class-readwrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using XSPF for Video Playlists.</title>
		<link>http://www.jonnyreeves.co.uk/2008/02/using-xspf-for-video-playlists/</link>
		<comments>http://www.jonnyreeves.co.uk/2008/02/using-xspf-for-video-playlists/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 16:36:15 +0000</pubDate>
		<dc:creator>Jonny</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>
		<category><![CDATA[Video on the Web]]></category>
		<category><![CDATA[playlist]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xspf]]></category>

		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=24</guid>
		<description><![CDATA[I am working to implement the XSPF Playlist standard for CNET Networks UK Video Players (with the hope that it could one day move to other countries).  XSPF describes itself as being an XML based playlist format for digital media and is sponsored by the Xiph.Org Foundation.
I have been trying to keep the implementation [...]]]></description>
			<content:encoded><![CDATA[<p>I am working to implement the XSPF Playlist standard for CNET Networks UK Video Players (with the hope that it could one day move to other countries).  XSPF describes itself as being an XML based playlist format for digital media and is sponsored by the <a href="http://en.wikipedia.org/wiki/Xiph.Org_Foundation" title="Xiph.Org Foundation">Xiph.Org Foundation</a>.</p>
<p>I have been trying to keep the implementation as close to the <a href="http://xspf.org/xspf-v1.html">vanilla XSPF Version 1.0 schema</a> as possible and keeping all CNET Specific data in &lt;meta&gt; and &lt;extension&gt; enclosures with accurate rel URIs.  I am going to spend the next few working days attempting to implement this template into the next version of the CNET Networks UK Player and creating the parent script which will generate them from our CMS.</p>
<p>For those that are interested my current XSPF schema follows:<span id="more-24"></span></p>
<div class="dean_ch" style="white-space: nowrap; overflow: scroll;"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;UTF-8&quot;</span><span class="re2">?&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;playlist</span> <span class="re0">version</span>=<span class="st0">&quot;1&quot;</span> <span class="re0">xmlns</span>=<span class="st0">&quot;http://xspf.org/ns/0/&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp;<span class="sc3"><span class="re1">&lt;title<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/title<span class="re2">&gt;</span></span></span><br />
&nbsp;<span class="sc3"><span class="re1">&lt;creator<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/creator<span class="re2">&gt;</span></span></span> <br />
&nbsp;<span class="sc3"><span class="re1">&lt;date<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/date<span class="re2">&gt;</span></span></span><br />
&nbsp;<span class="sc3"><span class="re1">&lt;extension</span> <span class="re0">application</span>=<span class="st0">&quot;http://www.cnetnetworks.co.uk/xspf/reccomendations/1/0/&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;cnet:reccomendation<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;cnet:title<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/cnet:title<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;cnet:image<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/cnet:image<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;cnet:info<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/cnet:info<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;cnet:annotation<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/cnet:annotation<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/cnet:reccomendation<span class="re2">&gt;</span></span></span><br />
&nbsp;<span class="sc3"><span class="re1">&lt;/extension<span class="re2">&gt;</span></span></span><br />
&nbsp;<span class="sc3"><span class="re1">&lt;trackList<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;track<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;location<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/location<span class="re2">&gt;</span></span></span> &nbsp;<br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;title<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/title<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;creator<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/creator<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;annotation<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/annotation<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;info<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/info<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;image<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/image<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;duration<span class="re2">&gt;</span></span></span>1<span class="sc3"><span class="re1">&lt;/duration<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;meta</span> <span class="re0">rel</span>=<span class="st0">&quot;http://www.cnetnetworks.co.uk/xspf/product_id/1/0/&quot;</span><span class="re2">&gt;</span></span><span class="sc3"><span class="re1">&lt;/meta<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;meta</span> <span class="re0">rel</span>=<span class="st0">&quot;http://www.cnetnetworks.co.uk/xspf/is_ad/1/0/&quot;</span><span class="re2">&gt;</span></span><span class="sc3"><span class="re1">&lt;/meta<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;meta</span> <span class="re0">rel</span>=<span class="st0">&quot;http://www.cnetnetworks.co.uk/xspf/alternative_audio/1/0/&quot;</span><span class="re2">&gt;</span></span><span class="sc3"><span class="re1">&lt;/meta<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;meta</span> <span class="re0">rel</span>=<span class="st0">&quot;http://www.cnetnetworks.co.uk/xspf/captions_file/1/0/&quot;</span><span class="re2">&gt;</span></span><span class="sc3"><span class="re1">&lt;/meta<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;extension</span> <span class="re0">application</span>=<span class="st0">&quot;http://www.cnetnetworks.co.uk/xspf/chapters/1/0/&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;cnet:chapter<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;cnet:title<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/cnet:title<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;cnet:image<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/cnet:image<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;cnet:annotation<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/cnet:annotation<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;cnet:position<span class="re2">&gt;</span></span></span><span class="sc3"><span class="re1">&lt;/cnet:position<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/cnet:chapter<span class="re2">&gt;</span></span></span> <br />
&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;/extension<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/track<span class="re2">&gt;</span></span></span><br />
&nbsp;<span class="sc3"><span class="re1">&lt;/trackList<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/playlist<span class="re2">&gt;</span></span></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.jonnyreeves.co.uk/2008/02/using-xspf-for-video-playlists/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
