<?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; events</title>
	<atom:link href="http://www.jonnyreeves.co.uk/tag/events/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>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>
	</channel>
</rss>
