<?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: getDefinitionByName</title>
	<atom:link href="http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/</link>
	<description>There is no universally agreed-upon biological definition of dreaming</description>
	<lastBuildDate>Wed, 28 Jul 2010 11:46:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Chris</title>
		<link>http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/comment-page-1/#comment-1110</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Tue, 25 May 2010 01:34:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/#comment-1110</guid>
		<description>Hey,
I want to load classes dynamically and reflect their properties at runtime without actually having any references, or importing them.  Is there any way to do this without adding the swc&#039;s to the -include-libraries field?  In my case there can be any number of swc&#039;s in a directory at a time that I want to load classes from.  Some could be removed, and some could be added.  So having this command line argument doesn&#039;t really work for me.  Thanks!</description>
		<content:encoded><![CDATA[<p>Hey,<br />
I want to load classes dynamically and reflect their properties at runtime without actually having any references, or importing them.  Is there any way to do this without adding the swc&#8217;s to the -include-libraries field?  In my case there can be any number of swc&#8217;s in a directory at a time that I want to load classes from.  Some could be removed, and some could be added.  So having this command line argument doesn&#8217;t really work for me.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Collin</title>
		<link>http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/comment-page-1/#comment-1057</link>
		<dc:creator>Collin</dc:creator>
		<pubDate>Wed, 18 Nov 2009 20:22:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/#comment-1057</guid>
		<description>Relative paths seem to work fine in Flex 3 on a Mac... 
-include-libraries ./../libs/myswc.swc

But I haven&#039;t tried opening the same file with a windows version yet...</description>
		<content:encoded><![CDATA[<p>Relative paths seem to work fine in Flex 3 on a Mac&#8230;<br />
-include-libraries ./../libs/myswc.swc</p>
<p>But I haven&#8217;t tried opening the same file with a windows version yet&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lebowskisrug</title>
		<link>http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/comment-page-1/#comment-799</link>
		<dc:creator>lebowskisrug</dc:creator>
		<pubDate>Fri, 23 Jan 2009 06:45:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/#comment-799</guid>
		<description>Dan:
Your problem is that getDefinitionByName() accepts class names as an input parameter, not variable names.  You could use your method if you created the MovieClips as separate classes, or exported them from the Flash GUI.  However, I think what you&#039;re looking for is the ability to reference dynamic variable names.  This is done using the this[&quot;variable_name&quot;] syntax.  Here&#039;s a quick example similar to yours:

package 
{
	import flash.display.DisplayObject;
	import flash.display.SpreadMethod;
	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.utils.Dictionary;
	import flash.utils.getDefinitionByName;

	public class Main extends Sprite 
	{
		private var man1Red:MovieClip = new MovieClip();
		private var man1Green:MovieClip = new MovieClip();
		private var man1Blue:MovieClip = new MovieClip();
		
		public function Main():void 
		{
			//red fill
			initGraphic(man1Red, 0xFF0000);
			//green fill
			initGraphic(man1Green, 0x00FF00);
			//blue fill
			initGraphic(man1Blue, 0x0000FF);
			
			showDirection(&quot;Red&quot;);
		}
		private function initGraphic(mc:MovieClip, color:uint):void
		{
			with (mc)
			{
				graphics.beginFill(color);
				graphics.drawRect(0, 0, 50, 50);
				graphics.endFill();
			}
		}
		private function showDirection(color:String):void 
		{
			if (this.numChildren &gt; 0)
			{
				removeChildAt(0);
			}
			addChildAt(this[&quot;man1&quot; + color], 0);
		}
	}
}</description>
		<content:encoded><![CDATA[<p>Dan:<br />
Your problem is that getDefinitionByName() accepts class names as an input parameter, not variable names.  You could use your method if you created the MovieClips as separate classes, or exported them from the Flash GUI.  However, I think what you&#8217;re looking for is the ability to reference dynamic variable names.  This is done using the this["variable_name"] syntax.  Here&#8217;s a quick example similar to yours:</p>
<p>package<br />
{<br />
	import flash.display.DisplayObject;<br />
	import flash.display.SpreadMethod;<br />
	import flash.display.Sprite;<br />
	import flash.display.MovieClip;<br />
	import flash.events.Event;<br />
	import flash.utils.Dictionary;<br />
	import flash.utils.getDefinitionByName;</p>
<p>	public class Main extends Sprite<br />
	{<br />
		private var man1Red:MovieClip = new MovieClip();<br />
		private var man1Green:MovieClip = new MovieClip();<br />
		private var man1Blue:MovieClip = new MovieClip();</p>
<p>		public function Main():void<br />
		{<br />
			//red fill<br />
			initGraphic(man1Red, 0xFF0000);<br />
			//green fill<br />
			initGraphic(man1Green, 0&#215;00FF00);<br />
			//blue fill<br />
			initGraphic(man1Blue, 0&#215;0000FF);</p>
<p>			showDirection(&#8220;Red&#8221;);<br />
		}<br />
		private function initGraphic(mc:MovieClip, color:uint):void<br />
		{<br />
			with (mc)<br />
			{<br />
				graphics.beginFill(color);<br />
				graphics.drawRect(0, 0, 50, 50);<br />
				graphics.endFill();<br />
			}<br />
		}<br />
		private function showDirection(color:String):void<br />
		{<br />
			if (this.numChildren &gt; 0)<br />
			{<br />
				removeChildAt(0);<br />
			}<br />
			addChildAt(this["man1" + color], 0);<br />
		}<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/comment-page-1/#comment-768</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Sat, 06 Dec 2008 15:54:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/#comment-768</guid>
		<description>If I do this:

	var man:Class = getDefinitionByName(&quot;man1&quot; + dir) as Class;
	var obj = new man() as DisplayObject;
	object.removeChildAt(0);
	object.addChild(obj);

I get this error:

	ReferenceError: Error #1065: Variable man1UR is not defined.

When, as you can see above, it is defined...?</description>
		<content:encoded><![CDATA[<p>If I do this:</p>
<p>	var man:Class = getDefinitionByName(&#8220;man1&#8243; + dir) as Class;<br />
	var obj = new man() as DisplayObject;<br />
	object.removeChildAt(0);<br />
	object.addChild(obj);</p>
<p>I get this error:</p>
<p>	ReferenceError: Error #1065: Variable man1UR is not defined.</p>
<p>When, as you can see above, it is defined&#8230;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/comment-page-1/#comment-767</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Sat, 06 Dec 2008 15:46:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/#comment-767</guid>
		<description>Hi,

I have something similar to this, all though not the same, I have no experience with SWC files.

I have defined 3 MovieClips:

	var man1DR:MovieClip = new MovieClip();
	var man1UL:MovieClip = new MovieClip();
	var man1UR:MovieClip = new MovieClip();

I want to add one of these to a movieClip as a child, depending on a variable &#039;dir&#039;.

&quot;man1&quot; + dir gives me the name of one of those 3 movieClips, but if I do:

object.addChild(&quot;man1&quot;+ dir);

I get an error as it is a string and not the actual movieClip. Do you know how I fix this??</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I have something similar to this, all though not the same, I have no experience with SWC files.</p>
<p>I have defined 3 MovieClips:</p>
<p>	var man1DR:MovieClip = new MovieClip();<br />
	var man1UL:MovieClip = new MovieClip();<br />
	var man1UR:MovieClip = new MovieClip();</p>
<p>I want to add one of these to a movieClip as a child, depending on a variable &#8216;dir&#8217;.</p>
<p>&#8220;man1&#8243; + dir gives me the name of one of those 3 movieClips, but if I do:</p>
<p>object.addChild(&#8220;man1&#8243;+ dir);</p>
<p>I get an error as it is a string and not the actual movieClip. Do you know how I fix this??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iestyn lloyd</title>
		<link>http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/comment-page-1/#comment-520</link>
		<dc:creator>iestyn lloyd</dc:creator>
		<pubDate>Wed, 15 Oct 2008 13:25:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/#comment-520</guid>
		<description>Hey, thanks for this, I was wondering WTF was going on for a while :)

FYI, I got a relative path working. If you&#039;re using FlashDevelop (3.0.0 Beta9), it needs to be relative to your .as3proj file.
This worked:  -include-libraries dev\swc\videos.swc</description>
		<content:encoded><![CDATA[<p>Hey, thanks for this, I was wondering WTF was going on for a while <img src='http://www.dreaminginflash.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>FYI, I got a relative path working. If you&#8217;re using FlashDevelop (3.0.0 Beta9), it needs to be relative to your .as3proj file.<br />
This worked:  -include-libraries dev\swc\videos.swc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sdgdg</title>
		<link>http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/comment-page-1/#comment-394</link>
		<dc:creator>sdgdg</dc:creator>
		<pubDate>Mon, 23 Jun 2008 10:32:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreaminginflash.com/2008/01/25/getdefinitionbyname/#comment-394</guid>
		<description>&lt;a href=&quot;http://www.laizjj.cn&quot; rel=&quot;nofollow&quot;&gt;å¼ å®¶ç•Œæ—…æ¸¸&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p><a href="http://www.laizjj.cn" rel="nofollow">å¼ å®¶ç•Œæ—…æ¸¸</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
