<?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>mandarin.no &#187; code</title>
	<atom:link href="http://mandarin.no/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://mandarin.no</link>
	<description></description>
	<lastBuildDate>Tue, 17 Aug 2010 09:35:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>AS3 Snippet #3: Remove all childs</title>
		<link>http://mandarin.no/as3/as3-snippet-3-remove-all-childs/</link>
		<comments>http://mandarin.no/as3/as3-snippet-3-remove-all-childs/#comments</comments>
		<pubDate>Sat, 02 May 2009 02:05:30 +0000</pubDate>
		<dc:creator>Thomas Viktil</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[child]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[eventhandler]]></category>
		<category><![CDATA[parent]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[removeChild]]></category>
		<category><![CDATA[snippet]]></category>
		<guid isPermaLink="false">http://mandarin.no/?p=79</guid>
		<description><![CDATA[I code snippet I tend to use quite often. And one that I tend to forget how I wrote the last time i used it. while (this.numChildren &#62; 0) {     removeChild(this.getChildAt(0)); } Update: And when you want to remove a child as a part of an event handler, do this: event.target.parent.removeChild(event.target); Let&#8217;s say [...]]]></description>
			<content:encoded><![CDATA[<p>I code snippet I tend to use quite often. And one that I tend to forget how I wrote the last time i used it.</p>
<pre>while (this.numChildren &gt; 0)
{
    removeChild(this.getChildAt(0));
}</pre>
<p><strong>Update:</strong></p>
<p>And when you want to remove a child as a part of an event handler, do this:</p>
<pre>event.target.parent.removeChild(event.target);</pre>
<p>Let&#8217;s say you want to delete the button you just clicked. The button dispatches an event, and this line of code goes in the event handler. event.target is the button (or what ever object you clicked). It does look at bit strange, because you have to tell the button that it&#8217;s parent should delete the button. The button can&#8217;t delete itself.</p>
<p><strong>Note:</strong></p>
<p>If you&#8217;re working with Flex, use <span style="color: #333333;"><strong>this.removeAllChildren();</strong></span> Thank you Bjørnar <img src='http://mandarin.no/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://mandarin.no/as3/as3-snippet-3-remove-all-childs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
