Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When you retrieve the <code>MovieClip</code> from your <code>Array</code>, you need to cast it as a <code>DisplayObject</code> before attempting to remove it: </p> <pre><code> if (thumbnails.length !== 0){ // Determine if any movieclips have already been created on stage and delete them for(var ctr:int = 0; ctr &lt; thumbnails.length;ctr++ ){ removeChild(DisplayObject(thumbnails[ctr])); } } </code></pre> <p>Alternatively, you could consider using a <code>Vector</code> (a type-safe version of an <code>Array</code>) with the base-type set as <code>DisplayObject</code>: </p> <pre><code>var thumbnails:Vector.&lt;DisplayObject&gt; = new Vector.&lt;DisplayObject&gt;(); thumbnails.push(new MovieClip()); this.addChild(thumbnails[0]); this.removeChild(thumbnails[0]); </code></pre> <p>For further reading, have a look at the Adobe documentation on <a href="http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f87.html" rel="nofollow">type conversion</a> and <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html" rel="nofollow"><code>Vectors</code></a>. </p> <p><strong>Update:</strong></p> <p>Instead of adding an instance of <code>Thumbnail</code> to your <code>Array</code> the following line is actually adding a further <code>Array</code> containing a single element to your thumbnails <code>Array</code> (in effect you are creating a multi-dimensional <code>Array</code>):</p> <pre><code>// You're assigning an array literal with a single element // to this element of the the thumbnails array thumbnails[i] = [thumb]; </code></pre> <p>Try either of the following instead: </p> <pre><code> // What you meant thumbnails[i] = thumb; // Better thumbnails.push(thumb); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload