<?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: Constructor Function</title>
	<atom:link href="http://jacksondunstan.com/articles/398/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/398</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Mon, 06 Sep 2010 21:17:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/398/comment-page-1#comment-341</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Sun, 01 Nov 2009 01:49:12 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=398#comment-341</guid>
		<description>A Google search for &quot;&lt;a href=&quot;http://www.google.com/search?q=as3+reflection&quot; rel=&quot;nofollow&quot;&gt;as3 reflection&lt;/a&gt;&quot; or &quot;&lt;a href=&quot;http://www.google.com/search?q=as3+reflect&quot; rel=&quot;nofollow&quot;&gt;as3 reflect&lt;/a&gt;&quot; doesn&#039;t take you to that project. I found their &lt;a href=&quot;http://code.google.com/p/as3-commons/&quot; rel=&quot;nofollow&quot;&gt;Google Code page&lt;/a&gt; though and dug around to find the &lt;a href=&quot;http://code.google.com/p/as3-commons/source/browse/trunk/as3-commons-lang/src/main/actionscript/org/as3commons/lang/ClassUtils.as&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;. It is indeed similar to my implementation. Anyone interested in a more complete library of reflection functions should check it out. I assure you though, I reached this solution without any knowledge of the &quot;AS3 Commons&quot; Google Code project. Thanks for pointing it out though; it&#039;s always nice to peruse open source AS3 to see what others are up to.</description>
		<content:encoded><![CDATA[<p>A Google search for &#8220;<a href="http://www.google.com/search?q=as3+reflection" rel="nofollow">as3 reflection</a>&#8221; or &#8220;<a href="http://www.google.com/search?q=as3+reflect" rel="nofollow">as3 reflect</a>&#8221; doesn&#8217;t take you to that project. I found their <a href="http://code.google.com/p/as3-commons/" rel="nofollow">Google Code page</a> though and dug around to find the <a href="http://code.google.com/p/as3-commons/source/browse/trunk/as3-commons-lang/src/main/actionscript/org/as3commons/lang/ClassUtils.as" rel="nofollow">source</a>. It is indeed similar to my implementation. Anyone interested in a more complete library of reflection functions should check it out. I assure you though, I reached this solution without any knowledge of the &#8220;AS3 Commons&#8221; Google Code project. Thanks for pointing it out though; it&#8217;s always nice to peruse open source AS3 to see what others are up to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gio</title>
		<link>http://jacksondunstan.com/articles/398/comment-page-1#comment-340</link>
		<dc:creator>gio</dc:creator>
		<pubDate>Sun, 01 Nov 2009 01:02:58 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=398#comment-340</guid>
		<description>If someone ever needs a way to dynamically...
- find the type of a class from an istance (that could happen to be of one in many different types...)
- create a new instance of the same class (whatever the constructor signature this class type has...)

a search on as3 reflection should take them to &quot;as3 reflect&quot; project on google code, where the 
org.as3commons.lang.ClassUtils.newInstance()
method does exactly what &#039;your&#039; MakeConstructorFunction does...</description>
		<content:encoded><![CDATA[<p>If someone ever needs a way to dynamically&#8230;<br />
- find the type of a class from an istance (that could happen to be of one in many different types&#8230;)<br />
- create a new instance of the same class (whatever the constructor signature this class type has&#8230;)</p>
<p>a search on as3 reflection should take them to &#8220;as3 reflect&#8221; project on google code, where the<br />
org.as3commons.lang.ClassUtils.newInstance()<br />
method does exactly what &#8216;your&#8217; MakeConstructorFunction does&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/398/comment-page-1#comment-318</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Fri, 23 Oct 2009 20:49:24 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=398#comment-318</guid>
		<description>Having a &lt;tt&gt;Function&lt;/tt&gt; object for a constructor means that you have the same type of object as with all the other methods of a class. Having a Class means that you have a problem in that you have a different type and therefore any variable that will hold a function of a class must be untyped (&lt;tt&gt;Object&lt;/tt&gt; or *) and then that you must write logic to check which type you have before &quot;calling&quot; it:

&lt;pre lang=&quot;actionscript3&quot;&gt;
if (func is Function)
{
    result = func();
}
else if (func is Class)
{
    result = new func();
}
else
{
    // now I have an error to handle
}
&lt;/pre&gt;

This could be useful for a variety of purposes, but most of them are examples of the above observation. One such example is that you might have a function that takes a &lt;tt&gt;Function&lt;/tt&gt;, not a &lt;tt&gt;Class&lt;/tt&gt; or an &lt;tt&gt;Object&lt;/tt&gt;, such as &lt;tt&gt;addEventListener()&lt;/tt&gt;, which you cannot or do not want to change. I can&#039;t give you the real world example that I needed this for, but suffice it to say that dealing with &lt;em&gt;both&lt;/em&gt; &lt;tt&gt;Class&lt;/tt&gt; and &lt;tt&gt;Function&lt;/tt&gt; types would have been extremely annoying.

It may be that you never have usage for &lt;tt&gt;makeConstructorFunction&lt;/tt&gt;. In fact, I think most people probably won&#039;t. But if you ever do, I hope you remember where you read about it. :)</description>
		<content:encoded><![CDATA[<p>Having a <tt>Function</tt> object for a constructor means that you have the same type of object as with all the other methods of a class. Having a Class means that you have a problem in that you have a different type and therefore any variable that will hold a function of a class must be untyped (<tt>Object</tt> or *) and then that you must write logic to check which type you have before &#8220;calling&#8221; it:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>func <span style="color: #0033ff; font-weight: bold;">is</span> <span style="color: #004993;">Function</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    result = func<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>func <span style="color: #0033ff; font-weight: bold;">is</span> <span style="color: #004993;">Class</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    result = <span style="color: #0033ff; font-weight: bold;">new</span> func<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #0033ff; font-weight: bold;">else</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #009900;">// now I have an error to handle</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This could be useful for a variety of purposes, but most of them are examples of the above observation. One such example is that you might have a function that takes a <tt>Function</tt>, not a <tt>Class</tt> or an <tt>Object</tt>, such as <tt>addEventListener()</tt>, which you cannot or do not want to change. I can&#8217;t give you the real world example that I needed this for, but suffice it to say that dealing with <em>both</em> <tt>Class</tt> and <tt>Function</tt> types would have been extremely annoying.</p>
<p>It may be that you never have usage for <tt>makeConstructorFunction</tt>. In fact, I think most people probably won&#8217;t. But if you ever do, I hope you remember where you read about it. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Clinkinbeard</title>
		<link>http://jacksondunstan.com/articles/398/comment-page-1#comment-317</link>
		<dc:creator>Ben Clinkinbeard</dc:creator>
		<pubDate>Fri, 23 Oct 2009 20:33:23 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=398#comment-317</guid>
		<description>I guess what I don&#039;t understand is If you already have the class and can create instances from it, why do you need/want a Function object?</description>
		<content:encoded><![CDATA[<p>I guess what I don&#8217;t understand is If you already have the class and can create instances from it, why do you need/want a Function object?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/398/comment-page-1#comment-316</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Fri, 23 Oct 2009 18:36:05 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=398#comment-316</guid>
		<description>That&#039;s not quite what I wanted to achieve. I want to be able to get a &lt;tt&gt;Function&lt;/tt&gt; object that, when called, creates an instance of a class that I already have. If you know of a way of doing this other than my monstrous hack, please let me know.</description>
		<content:encoded><![CDATA[<p>That&#8217;s not quite what I wanted to achieve. I want to be able to get a <tt>Function</tt> object that, when called, creates an instance of a class that I already have. If you know of a way of doing this other than my monstrous hack, please let me know.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Clinkinbeard</title>
		<link>http://jacksondunstan.com/articles/398/comment-page-1#comment-315</link>
		<dc:creator>Ben Clinkinbeard</dc:creator>
		<pubDate>Fri, 23 Oct 2009 18:18:19 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=398#comment-315</guid>
		<description>If you already have a reference to the class, which your function requires, you can just use the new operator on it.

&lt;pre lang=&quot;actionscript3&quot;&gt;
var c:Class = SomeClass;
var instance:SomeClass = new c( someArg, someOtherArg );
&lt;/pre&gt;

Does that do what you want or am I misunderstanding your goal?</description>
		<content:encoded><![CDATA[<p>If you already have a reference to the class, which your function requires, you can just use the new operator on it.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">c</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Class</span> = SomeClass;
<span style="color: #6699cc; font-weight: bold;">var</span> instance<span style="color: #000000; font-weight: bold;">:</span>SomeClass = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">c</span><span style="color: #000000;">&#40;</span> someArg, someOtherArg <span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>Does that do what you want or am I misunderstanding your goal?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
