<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>benwatts.ca &#187; displaylist</title>
	<atom:link href="http://www.benwatts.ca/tag/displaylist/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.benwatts.ca</link>
	<description>The crazy ramblings of designer/web developer Ben Watts.</description>
	<lastBuildDate>Sat, 02 Jan 2010 22:31:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>Removing Everything from a Display Container</title>
		<link>http://www.benwatts.ca/2008/05/25/removing-everything-from-a-display-container/</link>
		<comments>http://www.benwatts.ca/2008/05/25/removing-everything-from-a-display-container/#comments</comments>
		<pubDate>Mon, 26 May 2008 00:28:24 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[displaylist]]></category>

		<guid isPermaLink="false">http://seaturtle.rainiscold.ca/?p=48</guid>
		<description><![CDATA[I ran into this problem and couldn&#8217;t figure out what was going on because I fail miserably: // doesn't work because as this code executes numChildren is decreasing; // it ends up not removing everything for&#40;var i:Number=0; i &#38;lt; numChildren; i++&#41;&#123; &#160; removeChildAt&#40;i&#41;; &#125; The solution: while&#40; numChildren &#62; 0 &#41;&#123; &#160; removeChildAt&#40;0&#41;; &#125; This [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into this problem and couldn&#8217;t figure out what was going on <strong><em>because I fail miserably</em></strong>:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:540px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co1">// doesn't work because as this code executes numChildren is decreasing;</span><br />
<span class="co1">// it ends up not removing everything</span><br />
<span class="kw1">for</span><span class="br0">&#40;</span><span class="kw2">var</span> i<span class="sy0">:</span><span class="kw5">Number</span>=<span class="nu0">0</span>; i <span class="sy0">&amp;</span>lt; <span class="kw7">numChildren</span>; i<span class="sy0">++</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="kw7">removeChildAt</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div></div>
<p>The solution:</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:540px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">while</span><span class="br0">&#40;</span> <span class="kw7">numChildren</span> <span class="sy0">&gt;</span> <span class="nu0">0</span> <span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="kw7">removeChildAt</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div></div>
<p>This expression is useful for deleting things from the bottom of the displayList up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.benwatts.ca/2008/05/25/removing-everything-from-a-display-container/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sifting Through the Display List to Delete Things</title>
		<link>http://www.benwatts.ca/2008/05/19/sifting-through-the-display-list-to-delete-things/</link>
		<comments>http://www.benwatts.ca/2008/05/19/sifting-through-the-display-list-to-delete-things/#comments</comments>
		<pubDate>Mon, 19 May 2008 14:31:51 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[displaylist]]></category>

		<guid isPermaLink="false">http://seaturtle.rainiscold.ca/?p=44</guid>
		<description><![CDATA[Hah, it&#8217;s a pretty specific case &#8230; but this checks the last item of the display list and removes it if it partially matches (indexOf) the name on the display list item. This requires that the display list item to be given a name. var myClip:MovieClip = new MovieClip&#40;&#41;; myClip.name = &#34;thenameofit&#34;; if&#40; getChildAt&#40;numChildren-1&#41;.name.indexOf&#40;&#34;thenameofit&#34;&#41; &#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Hah, it&#8217;s a pretty specific case &#8230; but this checks the last item of the display list and removes it if it partially matches (indexOf) the name on the display list item. This requires that the display list item to be given a name.</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:540px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">var</span> myClip<span class="sy0">:</span><span class="kw5">MovieClip</span> = <span class="kw1">new</span> <span class="kw5">MovieClip</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
myClip.<span class="kw7">name</span> = <span class="st0">&quot;thenameofit&quot;</span>;<br />
<br />
<span class="kw1">if</span><span class="br0">&#40;</span> <span class="kw7">getChildAt</span><span class="br0">&#40;</span>numChildren<span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span>.<span class="kw7">name</span>.<span class="kw7">indexOf</span><span class="br0">&#40;</span><span class="st0">&quot;thenameofit&quot;</span><span class="br0">&#41;</span> <span class="sy0">&gt;</span> <span class="sy0">-</span><span class="nu0">1</span> <span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw7">removeChildAt</span><span class="br0">&#40;</span>numChildren<span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><br />
<span class="br0">&#125;</span></div></div>
<p>Yeah. Heh. So I&#8217;m keeping this code around, why? It could be used in the program I&#8217;m writing now, but it&#8217;s not nearly flexible enough as this, which loops through the display list and removes any child with containing a partially match of &#8220;deleteme&#8221;. Much more flexible, but also more intensive in a complex movie?</p>
<div class="codecolorer-container actionscript3 " style="overflow:auto;white-space:nowrap;width:540px"><div class="actionscript3 codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> i<span class="sy0">:</span><span class="kw5">int</span>=<span class="nu0">0</span>; i <span class="sy0">&lt;</span> <span class="kw1">this</span>.<span class="kw7">numChildren</span>; i<span class="sy0">++</span> <span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> <span class="kw7">getChildAt</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>.<span class="kw7">name</span>.<span class="kw7">indexOf</span><span class="br0">&#40;</span><span class="st0">'deleteme'</span><span class="br0">&#41;</span> <span class="sy0">&gt;</span> <span class="sy0">-</span><span class="nu0">1</span> <span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw7">removeChildAt</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.benwatts.ca/2008/05/19/sifting-through-the-display-list-to-delete-things/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
