Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can make an Interface IDestroy for example with a destroy method who will manage all cleaning/removing stuff :</p> <pre><code>public interface IDestroy{ function destroy():void; } public class MySprite extends Sprite implements IDestroy { .. public function destroy():void{ // remove events .. // remove loader .. //remove from parent if (parent!==null){ parent.removeChild(this); } // etc.. more cleaning } } </code></pre> <p>then when you have an object who is an instance of IDestroy you can call the destroy method</p> <pre><code>if (myObject is IDestroy){ IDestroy(myObject).destroy(); } </code></pre> <p>or another way</p> <pre><code>var id:IDestroy=myObject as IDestroy; if (id!==null) id.destroy(); </code></pre> <p>Edit:</p> <p>I don't understand why any of the method i gave you in the comment will not work but <code>_base.removeChild(_imgArray[i])</code> will :</p> <p><code>addChild</code> and <code>removeChild</code> accept only a <code>DisplayObject</code> as a parameter, so if you can do <code>_base.addChild(_imgArray[i])</code> it means that <code>_imgArray[i]</code> <strong>inherits from DisplayObject</strong> and <strong>_imgArray[i] has a parent</strong>.</p> <p>So <code>var myDisplayObject:DisplayObject=_imgArray[i] as DisplayObject;</code> will not return null and you will be able todo <code>myDisplayObject.parent.removeChild(myDisplayObject);</code> which is a general approach to your problem without relying on your _base DisplayObjectContainer (MovieClip/Sprite/...)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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