<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: getDefinitionByName trick</title>
	<atom:link href="http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/feed/" rel="self" type="application/rss+xml" />
	<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/</link>
	<description>actionscript, flex, flash and other fun stuff</description>
	<lastBuildDate>Sat, 14 Nov 2009 16:04:03 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: jwopitz</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-5027</link>
		<dc:creator>jwopitz</dc:creator>
		<pubDate>Fri, 21 Aug 2009 18:07:22 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-5027</guid>
		<description>Found this little trick that utilizes a metadata tag that compiles in classes for use with getDefinitionByName

http://www.rozengain.com/blog/2009/08/21/getdefinitionbyname-referenceerror-and-the-frame-metadata-tag/</description>
		<content:encoded><![CDATA[<p>Found this little trick that utilizes a metadata tag that compiles in classes for use with getDefinitionByName</p>
<p><a href="http://www.rozengain.com/blog/2009/08/21/getdefinitionbyname-referenceerror-and-the-frame-metadata-tag/" rel="nofollow">http://www.rozengain.com/blog/2009/08/21/getdefinitionbyname-referenceerror-and-the-frame-metadata-tag/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ben</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-5000</link>
		<dc:creator>ben</dc:creator>
		<pubDate>Tue, 04 Aug 2009 16:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-5000</guid>
		<description>If I understand this correctly, we no longer have to import the to be created class in the creating class, only in the to be created class do we register it as an alias.

So if we have A that we need to instantiate with getDefinitionByName(&#039;A&#039;) and we do not want to import A, then in the definition of A we registerClassAlias(&#039;A&#039;, A). Thereby we can use getDefinitionByName(&#039;A&#039;) anywhere without first importing it.

As far as I can tell, by using registerAlias, we are including the class in the running SWF, which only needs to happen once to be able to use getDefinitionByName.

Hmm but this does bring up an interesting cat and mouse problem. If we need to first instantiate A to call registerAlias, then it would have already been imported, in which case we needn&#039;t have registered it, because the class would need to be imported, loaded into the SWF, and instantiated somewhere for registerAlias to be called.</description>
		<content:encoded><![CDATA[<p>If I understand this correctly, we no longer have to import the to be created class in the creating class, only in the to be created class do we register it as an alias.</p>
<p>So if we have A that we need to instantiate with getDefinitionByName(&#8216;A&#8217;) and we do not want to import A, then in the definition of A we registerClassAlias(&#8216;A&#8217;, A). Thereby we can use getDefinitionByName(&#8216;A&#8217;) anywhere without first importing it.</p>
<p>As far as I can tell, by using registerAlias, we are including the class in the running SWF, which only needs to happen once to be able to use getDefinitionByName.</p>
<p>Hmm but this does bring up an interesting cat and mouse problem. If we need to first instantiate A to call registerAlias, then it would have already been imported, in which case we needn&#8217;t have registered it, because the class would need to be imported, loaded into the SWF, and instantiated somewhere for registerAlias to be called.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: heyitsleo</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-4996</link>
		<dc:creator>heyitsleo</dc:creator>
		<pubDate>Sun, 02 Aug 2009 07:17:32 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-4996</guid>
		<description>Guys I figured out the perfect solution for my specific problem but I have a feeling you can tweak your code to behave in a similar way.
&lt;code&gt;
var classNames:Array = [ClassA, ClassB, ClassC];
var classInstances:Object = {};
for each (className:Class in classNames) {
classInstances.push(new className());
}
&lt;/code&gt;
Hope that helps</description>
		<content:encoded><![CDATA[<p>Guys I figured out the perfect solution for my specific problem but I have a feeling you can tweak your code to behave in a similar way.<br />
<code><br />
var classNames:Array = [ClassA, ClassB, ClassC];<br />
var classInstances:Object = {};<br />
for each (className:Class in classNames) {<br />
classInstances.push(new className());<br />
}<br />
</code><br />
Hope that helps</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lqdice</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-4912</link>
		<dc:creator>lqdice</dc:creator>
		<pubDate>Sun, 21 Jun 2009 17:41:18 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-4912</guid>
		<description>I don&#039;t quite understand how this works. You&#039;re still pretty much explicitly defining the class you want to import. How is this any less work than doing the 

Box;

trick ?</description>
		<content:encoded><![CDATA[<p>I don&#8217;t quite understand how this works. You&#8217;re still pretty much explicitly defining the class you want to import. How is this any less work than doing the </p>
<p>Box;</p>
<p>trick ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sideDoor</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-4833</link>
		<dc:creator>sideDoor</dc:creator>
		<pubDate>Sat, 16 May 2009 21:20:24 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-4833</guid>
		<description>Hello,

As you describe above, I&#039;ve tried using registerClassAlias to assign a static variable in the class definition  AS3 (not Flex), and I still get the error:

ReferenceError: Error #1065: Variable MyClass is not defined.

Having applied your method above, I was trying to do something like this:

var dynClass:Class = Class(getDefinitionByName(&quot;fully.qualified.MyClass&quot;));
var dynObj = new dynClass();
addChild(dynObj);

Could you show a usage example?  Thanks</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>As you describe above, I&#8217;ve tried using registerClassAlias to assign a static variable in the class definition  AS3 (not Flex), and I still get the error:</p>
<p>ReferenceError: Error #1065: Variable MyClass is not defined.</p>
<p>Having applied your method above, I was trying to do something like this:</p>
<p>var dynClass:Class = Class(getDefinitionByName(&#8220;fully.qualified.MyClass&#8221;));<br />
var dynObj = new dynClass();<br />
addChild(dynObj);</p>
<p>Could you show a usage example?  Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jivita</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-4712</link>
		<dc:creator>jivita</dc:creator>
		<pubDate>Mon, 02 Mar 2009 00:31:31 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-4712</guid>
		<description>hi,

i tried this in flash and it didn&#039;t work.
i think it is the same problem like embedding somezhing with the [Embed()]</description>
		<content:encoded><![CDATA[<p>hi,</p>
<p>i tried this in flash and it didn&#8217;t work.<br />
i think it is the same problem like embedding somezhing with the [Embed()]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ptest</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-4706</link>
		<dc:creator>Ptest</dc:creator>
		<pubDate>Thu, 19 Feb 2009 23:05:32 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-4706</guid>
		<description>Can someone give me a quick example of a no-frills way to call it? Using the initial NestedObject - quick and dirty on the timeline I&#039;ve tried..

import vo.*;
import flash.utils.getDefinitionByName;
 //var uselessArray:Array =[NestedObject];

var Klass:Class  = getDefinitionByName(&quot;vo.NestedObject&quot;)  as 
Class;

// trace(getIt);
new Klass();

the only way it works is if I uncoment the 
uselessArray part 

Am I going about calling this class correctly?
thanks -</description>
		<content:encoded><![CDATA[<p>Can someone give me a quick example of a no-frills way to call it? Using the initial NestedObject &#8211; quick and dirty on the timeline I&#8217;ve tried..</p>
<p>import vo.*;<br />
import flash.utils.getDefinitionByName;<br />
 //var uselessArray:Array =[NestedObject];</p>
<p>var Klass:Class  = getDefinitionByName(&#8220;vo.NestedObject&#8221;)  as<br />
Class;</p>
<p>// trace(getIt);<br />
new Klass();</p>
<p>the only way it works is if I uncoment the<br />
uselessArray part </p>
<p>Am I going about calling this class correctly?<br />
thanks -</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jwopitz</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-4705</link>
		<dc:creator>jwopitz</dc:creator>
		<pubDate>Thu, 19 Feb 2009 21:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-4705</guid>
		<description>Have you tried it in flash?  The metadata tags, registerClass and getDefinitionByName are all basic as3, irrespective of your use of Flex.  I have not tried it myself in Flash but I would assume it works in Flash as it does in Flex.</description>
		<content:encoded><![CDATA[<p>Have you tried it in flash?  The metadata tags, registerClass and getDefinitionByName are all basic as3, irrespective of your use of Flex.  I have not tried it myself in Flash but I would assume it works in Flash as it does in Flex.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ptest</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-4704</link>
		<dc:creator>Ptest</dc:creator>
		<pubDate>Thu, 19 Feb 2009 19:51:13 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-4704</guid>
		<description>The project I&#039;m building is not in Flex so
I would really like to know if there is a way to accomplish this with just Flash (NOT flex). 

I use class names passed from an XML doc and use getDefinitionByName to use the strings as classes.

So far I&#039;ve created an (unused) array of all of the potential classes used which works but is really annoying  .. 

If there is a way to use the registerClass trick with Flash can someone please let us know?</description>
		<content:encoded><![CDATA[<p>The project I&#8217;m building is not in Flex so<br />
I would really like to know if there is a way to accomplish this with just Flash (NOT flex). </p>
<p>I use class names passed from an XML doc and use getDefinitionByName to use the strings as classes.</p>
<p>So far I&#8217;ve created an (unused) array of all of the potential classes used which works but is really annoying  .. </p>
<p>If there is a way to use the registerClass trick with Flash can someone please let us know?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bone</title>
		<link>http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/#comment-4646</link>
		<dc:creator>bone</dc:creator>
		<pubDate>Thu, 01 Jan 2009 10:51:22 +0000</pubDate>
		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=130#comment-4646</guid>
		<description>Apparently, this code only work if you compile your swf with Flex, due to the [ ] syntax ([RemoteClass(alias=&quot;vo.NestedObject&quot;)])...

If you compile the swf with the flash IDE, the [ ] call should&#039;nt be considered.

I had the same problem when I was trying to include fonts to the swf, without creating them in the library, but using the [] syntax, as described  in the Colin Mook&#039;s AS3 Book.



Could anyone confirm or cancel this assumption? 

For those who can&#039;t make the code working, are you devlopping with the Flash IDE?

For those who can get the code working, are you devlopping with the flex builder/sdk?



So far, the solution should be the found of a way to replace the [] call with an Flash IDE&#039;s  compiling option (if it exists!)...

Does anybody know something about that?</description>
		<content:encoded><![CDATA[<p>Apparently, this code only work if you compile your swf with Flex, due to the [ ] syntax ([RemoteClass(alias="vo.NestedObject")])&#8230;</p>
<p>If you compile the swf with the flash IDE, the [ ] call should&#8217;nt be considered.</p>
<p>I had the same problem when I was trying to include fonts to the swf, without creating them in the library, but using the [] syntax, as described  in the Colin Mook&#8217;s AS3 Book.</p>
<p>Could anyone confirm or cancel this assumption? </p>
<p>For those who can&#8217;t make the code working, are you devlopping with the Flash IDE?</p>
<p>For those who can get the code working, are you devlopping with the flex builder/sdk?</p>
<p>So far, the solution should be the found of a way to replace the [] call with an Flash IDE&#8217;s  compiling option (if it exists!)&#8230;</p>
<p>Does anybody know something about that?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
