<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: AS3 technique &#8212; using object instances as &#8220;enums&#8221;</title>
	<atom:link href="http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/feed/" rel="self" type="application/rss+xml" />
	<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/</link>
	<description>music, technology, interfaces</description>
	<lastBuildDate>Sun, 29 Jan 2012 05:22:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Samuel Asher Rivello</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-291359</link>
		<dc:creator>Samuel Asher Rivello</dc:creator>
		<pubDate>Wed, 12 Aug 2009 00:19:18 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-291359</guid>
		<description>Enums are my favorite community developed language feature!!!

An Enum is a kind of variable that is not natively available in ActionScript 3.0, but can be found in other languages such as C++. An enum is a type with a restricted set of values. 

Here is  a demo;
http://www.blog.rivello.org/?p=621</description>
		<content:encoded><![CDATA[<p>Enums are my favorite community developed language feature!!!</p>
<p>An Enum is a kind of variable that is not natively available in ActionScript 3.0, but can be found in other languages such as C++. An enum is a type with a restricted set of values. </p>
<p>Here is  a demo;<br />
<a href="http://www.blog.rivello.org/?p=621" rel="nofollow">http://www.blog.rivello.org/?p=621</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Troy Gardner</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-44751</link>
		<dc:creator>Troy Gardner</dc:creator>
		<pubDate>Mon, 30 Jul 2007 02:43:21 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-44751</guid>
		<description>Paco: the enum object is a full blown class so can have whatever id/strings you want to serialize, and as many methods as you want to marshal bac and forth (e.g. toXMLString(), fromXMLString());

Sho:
I profiled use of String/int,uint, number in switch statements and using &#039;enum&#039;s was fastest by 1/3 of the String time when you cache a refence locally. The reason for this is it uses identity (===) rather than value comparisons (==). I cache a copy. Here&#039;s some sample code

public static const A:MyEnum = MyEnum.A;

....
switch(someEnum){
case A:
break;
case B:
}</description>
		<content:encoded><![CDATA[<p>Paco: the enum object is a full blown class so can have whatever id/strings you want to serialize, and as many methods as you want to marshal bac and forth (e.g. toXMLString(), fromXMLString());</p>
<p>Sho:<br />
I profiled use of String/int,uint, number in switch statements and using &#8216;enum&#8217;s was fastest by 1/3 of the String time when you cache a refence locally. The reason for this is it uses identity (===) rather than value comparisons (==). I cache a copy. Here&#8217;s some sample code</p>
<p>public static const A:MyEnum = MyEnum.A;</p>
<p>&#8230;.<br />
switch(someEnum){<br />
case A:<br />
break;<br />
case B:<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paco</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-25487</link>
		<dc:creator>Paco</dc:creator>
		<pubDate>Thu, 17 May 2007 20:16:16 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-25487</guid>
		<description>The TypeSafe method is not really useful when you want to save this information into a database.  I would prefer to save a number.

A number is also easier to transport between the various software of a system.  From flex program to businessObject to database.

I want to ask for a specific enumeration type in my function parameter like the TypeSafe allow me, but I don&#039;t want to save this object into my database.  I want to save a byte no more!

Why they never build a real Enumeration structure in AS# !?</description>
		<content:encoded><![CDATA[<p>The TypeSafe method is not really useful when you want to save this information into a database.  I would prefer to save a number.</p>
<p>A number is also easier to transport between the various software of a system.  From flex program to businessObject to database.</p>
<p>I want to ask for a specific enumeration type in my function parameter like the TypeSafe allow me, but I don&#8217;t want to save this object into my database.  I want to save a byte no more!</p>
<p>Why they never build a real Enumeration structure in AS# !?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ivan</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-7899</link>
		<dc:creator>ivan</dc:creator>
		<pubDate>Thu, 28 Dec 2006 20:38:47 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-7899</guid>
		<description>The above approach still isn&#039;t quite &quot;typesafe&quot; since you can use &quot;new LoopResult()&quot; instead of one of the consts, which would pass compilation but would break the code at runtime. If constructors were allowed to be declared private, then it&#039;d be less of a kludge. Bottom line -- AS needs proper enums.</description>
		<content:encoded><![CDATA[<p>The above approach still isn&#8217;t quite &#8220;typesafe&#8221; since you can use &#8220;new LoopResult()&#8221; instead of one of the consts, which would pass compilation but would break the code at runtime. If constructors were allowed to be declared private, then it&#8217;d be less of a kludge. Bottom line &#8212; AS needs proper enums.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sho</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-236</link>
		<dc:creator>Sho</dc:creator>
		<pubDate>Wed, 05 Apr 2006 16:03:35 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-236</guid>
		<description>I&#039;m glad that Java 5 has enums and generics. Maybe we can get them into AS4? :-)

I started writing a reply here, but it ended up getting quite long so I&#039;m moving it to a new entry. Let me know what you think.
</description>
		<content:encoded><![CDATA[<p>I&#8217;m glad that Java 5 has enums and generics. Maybe we can get them into AS4? :-)</p>
<p>I started writing a reply here, but it ended up getting quite long so I&#8217;m moving it to a new entry. Let me know what you think.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Halm</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-235</link>
		<dc:creator>Jens Halm</dc:creator>
		<pubDate>Wed, 05 Apr 2006 15:08:06 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-235</guid>
		<description>But in Java 5 you can at least switch on &quot;real&quot; enums.

Btw: If only Adobe would not prevent private and protected constructors, it would make life so much easier for creating singletons and faking enums and abstract classes. Still don&#039;t know why they are not allowed any more...</description>
		<content:encoded><![CDATA[<p>But in Java 5 you can at least switch on &#8220;real&#8221; enums.</p>
<p>Btw: If only Adobe would not prevent private and protected constructors, it would make life so much easier for creating singletons and faking enums and abstract classes. Still don&#8217;t know why they are not allowed any more&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sho</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-234</link>
		<dc:creator>Sho</dc:creator>
		<pubDate>Tue, 04 Apr 2006 21:59:40 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-234</guid>
		<description>Peter: Great comments. I hadn&#039;t thought about the AS3 &quot;switch on any type&quot; aspect. 

Jason: Glad to see we&#039;re on the same page. Thanks for the link.</description>
		<content:encoded><![CDATA[<p>Peter: Great comments. I hadn&#8217;t thought about the AS3 &#8220;switch on any type&#8221; aspect. </p>
<p>Jason: Glad to see we&#8217;re on the same page. Thanks for the link.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Nussbaum</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-233</link>
		<dc:creator>Jason Nussbaum</dc:creator>
		<pubDate>Tue, 04 Apr 2006 21:39:37 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-233</guid>
		<description>I blogged something like that for AS 2 way back...
&lt;a href=&quot;http://blog.jasonnussbaum.com/?p=48&quot; rel=&quot;nofollow&quot;&gt;http://blog.jasonnussbaum.com/?p=48&lt;/a&gt;

With some added toString methods and all that jazz...</description>
		<content:encoded><![CDATA[<p>I blogged something like that for AS 2 way back&#8230;<br />
<a href="http://blog.jasonnussbaum.com/?p=48" rel="nofollow">http://blog.jasonnussbaum.com/?p=48</a></p>
<p>With some added toString methods and all that jazz&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Campbell</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-232</link>
		<dc:creator>Campbell</dc:creator>
		<pubDate>Tue, 04 Apr 2006 21:23:38 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-232</guid>
		<description>Yeah cool,
I have been doing similar, thought id try it after using the internal struc &amp; enum class types in c#.

Cam</description>
		<content:encoded><![CDATA[<p>Yeah cool,<br />
I have been doing similar, thought id try it after using the internal struc &amp; enum class types in c#.</p>
<p>Cam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://kuwamoto.org/2006/04/04/as3-technique-using-object-instances-as-enums/comment-page-1/#comment-231</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 04 Apr 2006 20:07:59 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=53#comment-231</guid>
		<description>This technique is particularly nice in AS3, compared to Java, because AS3 lets you switch on any type. But I&#039;d still consider adding a string property to the class, for use in debugging.</description>
		<content:encoded><![CDATA[<p>This technique is particularly nice in AS3, compared to Java, because AS3 lets you switch on any type. But I&#8217;d still consider adding a string property to the class, for use in debugging.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

