<?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: Get the class used to create an object instance in AS3</title>
	<atom:link href="http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/</link>
	<description>Josh Tynjala explores Flash, Flex, and ActionScript.</description>
	<lastBuildDate>Sat, 31 Jul 2010 02:55:11 -0400</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: websites accesed so far to help understand ActionScript 3 &#171; Dave Potts Blog</title>
		<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/comment-page-1/#comment-62787</link>
		<dc:creator>websites accesed so far to help understand ActionScript 3 &#171; Dave Potts Blog</dc:creator>
		<pubDate>Wed, 10 Feb 2010 20:11:24 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=608#comment-62787</guid>
		<description>[...] Get the class used to create an object instance in AS3 &#8211; Josh Talks Flash [...]</description>
		<content:encoded><![CDATA[<p>[...] Get the class used to create an object instance in AS3 &#8211; Josh Talks Flash [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: intense creativity &#187; SWF TextField Factory &#8212; Dynamically Loading Fonts in AS3</title>
		<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/comment-page-1/#comment-61966</link>
		<dc:creator>intense creativity &#187; SWF TextField Factory &#8212; Dynamically Loading Fonts in AS3</dc:creator>
		<pubDate>Fri, 11 Dec 2009 05:05:56 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=608#comment-61966</guid>
		<description>[...] like the FontAsset class.. how do I get a pure Font class? After some researching, I find this post which describes the &quot;constructor&quot; property of all objects.. cool. This will let you simulate [...]</description>
		<content:encoded><![CDATA[<p>[...] like the FontAsset class.. how do I get a pure Font class? After some researching, I find this post which describes the &quot;constructor&quot; property of all objects.. cool. This will let you simulate [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeff</title>
		<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/comment-page-1/#comment-61017</link>
		<dc:creator>jeff</dc:creator>
		<pubDate>Fri, 05 Jun 2009 20:51:58 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=608#comment-61017</guid>
		<description>Sweet, thanks.  I have been wondering how to do that for a little while now.</description>
		<content:encoded><![CDATA[<p>Sweet, thanks.  I have been wondering how to do that for a little while now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/comment-page-1/#comment-61016</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Fri, 05 Jun 2009 18:14:41 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=608#comment-61016</guid>
		<description>There is no way to get the object that called a function, unless you require that it gets explicitly passed in. Something like this would work:

&lt;pre&gt;public function setExample(exampleValue:Object, caller:SpecialType):void
{
    if(caller == null)
    {
        throw new Error(&quot;Caller must be of type SpecialType.&quot;);
    }
    this._example = exampleValue;
}&lt;/pre&gt;

Personally, I don&#039;t like that approach. A better one might be to use namespaces.

You can define the same namespace separately in each class:

&lt;pre&gt;private namespace only_special_type = &quot;http://www.example.com/only_special_type&quot;;&lt;/pre&gt;

...and then use it instead of public for your setter:

&lt;pre&gt;only_special_type function set example(value:Object):void
{
    this._example = value;
}&lt;/pre&gt;

That won&#039;t stop people from using your setter if they know how to define the same namespace, but they&#039;ll have to explicitly make that choice, so it adds a stronger barrier to entry.</description>
		<content:encoded><![CDATA[<p>There is no way to get the object that called a function, unless you require that it gets explicitly passed in. Something like this would work:</p>
<pre>public function setExample(exampleValue:Object, caller:SpecialType):void
{
    if(caller == null)
    {
        throw new Error("Caller must be of type SpecialType.");
    }
    this._example = exampleValue;
}</pre>
<p>Personally, I don&#8217;t like that approach. A better one might be to use namespaces.</p>
<p>You can define the same namespace separately in each class:</p>
<pre>private namespace only_special_type = "http://www.example.com/only_special_type";</pre>
<p>&#8230;and then use it instead of public for your setter:</p>
<pre>only_special_type function set example(value:Object):void
{
    this._example = value;
}</pre>
<p>That won&#8217;t stop people from using your setter if they know how to define the same namespace, but they&#8217;ll have to explicitly make that choice, so it adds a stronger barrier to entry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeff</title>
		<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/comment-page-1/#comment-61015</link>
		<dc:creator>jeff</dc:creator>
		<pubDate>Fri, 05 Jun 2009 17:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=608#comment-61015</guid>
		<description>Would there be a way, using this method, to determine in a setter function what class was trying to set the value in another class?

So if a variable was only supposed to be able to be set from a specific class, others would error out?</description>
		<content:encoded><![CDATA[<p>Would there be a way, using this method, to determine in a setter function what class was trying to set the value in another class?</p>
<p>So if a variable was only supposed to be able to be set from a specific class, others would error out?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Reidy</title>
		<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/comment-page-1/#comment-60955</link>
		<dc:creator>Justin Reidy</dc:creator>
		<pubDate>Wed, 13 May 2009 12:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=608#comment-60955</guid>
		<description>I was just about to ask about the relative speeds - should have known you&#039;d check, Ben!

This is great stuff, Josh. Thanks for the post.</description>
		<content:encoded><![CDATA[<p>I was just about to ask about the relative speeds &#8211; should have known you&#8217;d check, Ben!</p>
<p>This is great stuff, Josh. Thanks for the post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Clinkinbeard</title>
		<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/comment-page-1/#comment-60949</link>
		<dc:creator>Ben Clinkinbeard</dc:creator>
		<pubDate>Tue, 12 May 2009 14:16:04 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=608#comment-60949</guid>
		<description>Nice find Josh, I wasn&#039;t familiar with this approach. Not only does it look cleaner in my opinion but based on some rudimentary testing it appears to be about 4 times faster as well.</description>
		<content:encoded><![CDATA[<p>Nice find Josh, I wasn&#8217;t familiar with this approach. Not only does it look cleaner in my opinion but based on some rudimentary testing it appears to be about 4 times faster as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roland Zwaga</title>
		<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/comment-page-1/#comment-60948</link>
		<dc:creator>Roland Zwaga</dc:creator>
		<pubDate>Tue, 12 May 2009 08:03:17 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=608#comment-60948</guid>
		<description>The as3-commons projects came forth out of Spring Actionscript and offers quite an extensive reflection library, you might like to check it out here:

&lt;a href=&quot;http://www.as3commons.org/as3-commons-reflect/index.html&quot; rel=&quot;nofollow&quot;&gt;AS3 Commons Reflect&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>The as3-commons projects came forth out of Spring Actionscript and offers quite an extensive reflection library, you might like to check it out here:</p>
<p><a href="http://www.as3commons.org/as3-commons-reflect/index.html" rel="nofollow">AS3 Commons Reflect</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Campbell</title>
		<link>http://joshblog.net/2009/05/11/retrieve-the-class-used-to-instantiate-an-object-in-as3/comment-page-1/#comment-60947</link>
		<dc:creator>Campbell</dc:creator>
		<pubDate>Mon, 11 May 2009 21:08:27 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=608#comment-60947</guid>
		<description>I have wrapped the flash.utils methods in a Util class that caches the object definitions... seeing Class definitions are static, it works out pretty well. That way I can cache all sorts of metadata etc on the classes. 

This is the first time I have really seen any use for the constructor property though well done :)

If I find time ill clean it up and post a link</description>
		<content:encoded><![CDATA[<p>I have wrapped the flash.utils methods in a Util class that caches the object definitions&#8230; seeing Class definitions are static, it works out pretty well. That way I can cache all sorts of metadata etc on the classes. </p>
<p>This is the first time I have really seen any use for the constructor property though well done <img src='http://joshblog.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If I find time ill clean it up and post a link</p>
]]></content:encoded>
	</item>
</channel>
</rss>
