<?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: Creating unique identifiers for objects using the getUID() method</title>
	<atom:link href="http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: dormouse</title>
		<link>http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/comment-page-1/#comment-1767</link>
		<dc:creator>dormouse</dc:creator>
		<pubDate>Sat, 03 Nov 2007 09:40:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/#comment-1767</guid>
		<description>Thanks for you tips,
i will try them.</description>
		<content:encoded><![CDATA[<p>Thanks for you tips,<br />
i will try them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/comment-page-1/#comment-1768</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Fri, 02 Nov 2007 15:28:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/#comment-1768</guid>
		<description>dormouse,

And an excellent question that is. The MovieClip class changed somewhat significantly between ActionScript 2.0 and ActionScript 3.0. Now, in ActionScript 3.0 you use the &quot;new MovieClip()&quot; constructor to create a new movie clip (which is a lot more consistent with the rest of the Flash Player API, ie: new Sprite(), new MovieClip(), new Array(), new Date(), new Video(), etc).

As for depth, there are several methods for handling depth. In no particular order:
&lt;pre class=&quot;code&quot;&gt;
addChildAt(child:DisplayObject, index:int):DisplayObject
getChildAt(index:int):DisplayObject
getChildIndex(child:DisplayObject):int
removeChildAt(index:int):DisplayObject
setChildIndex(child:DisplayObject, index:int):void
swapChildren(child1:DisplayObject, child2:DisplayObject):void
swapChildrenAt(index1:int, index2:int):void
&lt;/pre&gt;

(Taken from the &lt;a href=&quot;http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/MovieClip.html&quot; rel=&quot;nofollow&quot;&gt;MovieClip class in the Flash CS3 LiveDocs&lt;/a&gt;.)

So, the general idea is that the &quot;DisplayObject&quot; in question is your MovieClip symbol, and the &quot;index&quot; is the current depth (or desired depth, depending on the method).

Here&#039;s a pretty crude example of a few of the methods (I tested this in the main timeline of Flash CS3, since I already had it open, you may need to tweak somewhat if you&#039;re using Flex):
&lt;pre class=&quot;code&quot;&gt;
var box1:MovieClip = new MovieClip();
box1.graphics.beginFill(0xFF0000, 0.1);
box1.graphics.drawRect(0, 0, 100, 100);
box1.graphics.endFill();
box1.x = 10;
box1.y = 10;
addChild(box1);

var box2:MovieClip = new MovieClip();
box2.graphics.beginFill(0x00FF00, 0.2);
box2.graphics.drawRect(0, 0, 100, 100);
box2.graphics.endFill();
box2.x = 30;
box2.y = 40;
addChildAt(box2, 0);

var label1:TextField = new TextField();
label1.autoSize = TextFieldAutoSize.LEFT;
label1.text = String(getChildIndex(box1));
box1.addChild(label1);

var label2:TextField = new TextField();
label2.autoSize = TextFieldAutoSize.LEFT;
label2.text = String(getChildIndex(box2));
box2.addChild(label2);
&lt;/pre&gt;

For more information, you can read the &lt;a href=&quot;http://livedocs.adobe.com/flash/9.0/main/00000141.html&quot; rel=&quot;nofollow&quot;&gt;&quot;Display programming&quot; chapter of Programming ActionScript 3.0&lt;/a&gt;.

Hope that helps,
Peter</description>
		<content:encoded><![CDATA[<p>dormouse,</p>
<p>And an excellent question that is. The MovieClip class changed somewhat significantly between ActionScript 2.0 and ActionScript 3.0. Now, in ActionScript 3.0 you use the &#8220;new MovieClip()&#8221; constructor to create a new movie clip (which is a lot more consistent with the rest of the Flash Player API, ie: new Sprite(), new MovieClip(), new Array(), new Date(), new Video(), etc).</p>
<p>As for depth, there are several methods for handling depth. In no particular order:</p>
<pre class="code">
addChildAt(child:DisplayObject, index:int):DisplayObject
getChildAt(index:int):DisplayObject
getChildIndex(child:DisplayObject):int
removeChildAt(index:int):DisplayObject
setChildIndex(child:DisplayObject, index:int):void
swapChildren(child1:DisplayObject, child2:DisplayObject):void
swapChildrenAt(index1:int, index2:int):void
</pre>
<p>(Taken from the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/MovieClip.html" rel="nofollow">MovieClip class in the Flash CS3 LiveDocs</a>.)</p>
<p>So, the general idea is that the &#8220;DisplayObject&#8221; in question is your MovieClip symbol, and the &#8220;index&#8221; is the current depth (or desired depth, depending on the method).</p>
<p>Here&#8217;s a pretty crude example of a few of the methods (I tested this in the main timeline of Flash CS3, since I already had it open, you may need to tweak somewhat if you&#8217;re using Flex):</p>
<pre class="code">
var box1:MovieClip = new MovieClip();
box1.graphics.beginFill(0xFF0000, 0.1);
box1.graphics.drawRect(0, 0, 100, 100);
box1.graphics.endFill();
box1.x = 10;
box1.y = 10;
addChild(box1);

var box2:MovieClip = new MovieClip();
box2.graphics.beginFill(0x00FF00, 0.2);
box2.graphics.drawRect(0, 0, 100, 100);
box2.graphics.endFill();
box2.x = 30;
box2.y = 40;
addChildAt(box2, 0);

var label1:TextField = new TextField();
label1.autoSize = TextFieldAutoSize.LEFT;
label1.text = String(getChildIndex(box1));
box1.addChild(label1);

var label2:TextField = new TextField();
label2.autoSize = TextFieldAutoSize.LEFT;
label2.text = String(getChildIndex(box2));
box2.addChild(label2);
</pre>
<p>For more information, you can read the <a href="http://livedocs.adobe.com/flash/9.0/main/00000141.html" rel="nofollow">&#8220;Display programming&#8221; chapter of Programming ActionScript 3.0</a>.</p>
<p>Hope that helps,<br />
Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dormouse</title>
		<link>http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/comment-page-1/#comment-1769</link>
		<dc:creator>dormouse</dc:creator>
		<pubDate>Fri, 02 Nov 2007 12:33:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/#comment-1769</guid>
		<description>peterd,
i am sorry to bother you again, i have a problem about convert MovieClip from as2.0 to as3.0. in as2.0, MovieClip has a method calling createEmptyMovieClip(String name, int depth), but in as3.0, the MovieClip doesn&#039;t have this method. How to convert, especeilly , how to solution the depth?
Thanks!

dormouse</description>
		<content:encoded><![CDATA[<p>peterd,<br />
i am sorry to bother you again, i have a problem about convert MovieClip from as2.0 to as3.0. in as2.0, MovieClip has a method calling createEmptyMovieClip(String name, int depth), but in as3.0, the MovieClip doesn&#8217;t have this method. How to convert, especeilly , how to solution the depth?<br />
Thanks!</p>
<p>dormouse</p>
]]></content:encoded>
	</item>
</channel>
</rss>

