<?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: Clearing an Array or Vector</title>
	<atom:link href="http://jacksondunstan.com/articles/145/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/145</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Mon, 14 May 2012 17:02:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: skyboy</title>
		<link>http://jacksondunstan.com/articles/145/comment-page-1#comment-9610</link>
		<dc:creator>skyboy</dc:creator>
		<pubDate>Wed, 27 Jul 2011 19:05:53 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=145#comment-9610</guid>
		<description>There&#039;s also this:

&lt;pre lang=&quot;actionscript3&quot;&gt;var i:int = vec.length, f:Boolean = vec.fixed;
vec.fixed = false;
vec.length = 0;
vec.length = i;
vec.fixed = f;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>There&#8217;s also this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = vec<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">,</span> f<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = vec<span style="color: #000066; font-weight: bold;">.</span>fixed<span style="color: #000066; font-weight: bold;">;</span>
vec<span style="color: #000066; font-weight: bold;">.</span>fixed = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
vec<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
vec<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> = i<span style="color: #000066; font-weight: bold;">;</span>
vec<span style="color: #000066; font-weight: bold;">.</span>fixed = f<span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/145/comment-page-1#comment-9599</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Wed, 27 Jul 2011 16:18:07 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=145#comment-9599</guid>
		<description>That would be a different meaning for &quot;clear&quot;. In the article, I used the term to mean &quot;make the &lt;code&gt;Array&lt;/code&gt;/&lt;code&gt;Vector&lt;/code&gt; have zero length&quot;. But since a non-zero length fixed-length &lt;code&gt;Vector&lt;/code&gt; can&#039;t have its length changed to zero, you would want to &quot;clear&quot; it by changing its values back to a default. For that, the best you can do is a &lt;code&gt;for&lt;/code&gt; loop:

&lt;pre lang=&quot;actionscript3&quot;&gt;
for (var i:uint, len:uint=myVector.length; i &lt; len; ++i)
{
    myVector[i] = null; // or whatever you want to be the default (e.g. 0, false)
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>That would be a different meaning for &#8220;clear&#8221;. In the article, I used the term to mean &#8220;make the <code>Array</code>/<code>Vector</code> have zero length&#8221;. But since a non-zero length fixed-length <code>Vector</code> can&#8217;t have its length changed to zero, you would want to &#8220;clear&#8221; it by changing its values back to a default. For that, the best you can do is a <code>for</code> loop:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span><span style="color: #000066; font-weight: bold;">,</span> len<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span>=myVector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> len<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">++</span>i<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    myVector<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// or whatever you want to be the default (e.g. 0, false)</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://jacksondunstan.com/articles/145/comment-page-1#comment-9592</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 27 Jul 2011 10:15:33 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=145#comment-9592</guid>
		<description>This is all well and good, but what about when you want to clear a fixed length Vector such as one created like this:

myVector = new Vector.(3, true);

It&#039;s going to throw an error if you try to set myVector.length = 0;</description>
		<content:encoded><![CDATA[<p>This is all well and good, but what about when you want to clear a fixed length Vector such as one created like this:</p>
<p>myVector = new Vector.(3, true);</p>
<p>It&#8217;s going to throw an error if you try to set myVector.length = 0;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/145/comment-page-1#comment-1083</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Mon, 25 Oct 2010 16:35:49 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=145#comment-1083</guid>
		<description>Yep, like in AS2 and JavaScript, the &lt;code&gt;[]&lt;/code&gt; syntax alone evaluates to a new &lt;code&gt;Array&lt;/code&gt; object. Since you (unfortuantely) can&#039;t assign an &lt;code&gt;Array&lt;/code&gt; to a &lt;code&gt;Vector&lt;/code&gt;, you should get a compiler error.

The more you read about &lt;code&gt;Array&lt;/code&gt; and &lt;code&gt;Vector&lt;/code&gt;, the more strange they get. Try doing a search for &lt;a href=&quot;/?s=array&quot; rel=&quot;nofollow&quot;&gt;Array&lt;/a&gt; or &lt;a href=&quot;/?s=vector&quot; rel=&quot;nofollow&quot;&gt;Vector&lt;/a&gt; on this site for tons more information. Happy reading!</description>
		<content:encoded><![CDATA[<p>Yep, like in AS2 and JavaScript, the <code>[]</code> syntax alone evaluates to a new <code>Array</code> object. Since you (unfortuantely) can&#8217;t assign an <code>Array</code> to a <code>Vector</code>, you should get a compiler error.</p>
<p>The more you read about <code>Array</code> and <code>Vector</code>, the more strange they get. Try doing a search for <a href="/?s=array" rel="nofollow">Array</a> or <a href="/?s=vector" rel="nofollow">Vector</a> on this site for tons more information. Happy reading!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon C</title>
		<link>http://jacksondunstan.com/articles/145/comment-page-1#comment-1075</link>
		<dc:creator>Simon C</dc:creator>
		<pubDate>Mon, 25 Oct 2010 09:55:33 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=145#comment-1075</guid>
		<description>Although a Vector can use Array-like methods and member access such as vec[i] this article made me discover that unlike Arrays, a whole Vector cannot be cleared using vec = []</description>
		<content:encoded><![CDATA[<p>Although a Vector can use Array-like methods and member access such as vec[i] this article made me discover that unlike Arrays, a whole Vector cannot be cleared using vec = []</p>
]]></content:encoded>
	</item>
</channel>
</rss>

