title: Actionscript: Am I deleting this class instance correctly?
body: <p>Okay by deleting correctly I mean am I actually getting rid of the instance or is it just not being drawn anymore? I should mention that I'm trying to delete the instance from within its own class, that is it deletes itself. It 'works' in that the square it draws no longer appears on the screen but again I'm not sure if it's really gone or just not being drawn. Anyway here's the class: </p>
  
  <pre><code>package
  {
      import flash.display.*;
      import flash.events.*;
      public class OBJECT_bullet_1 extends Sprite
      {
          public var X:int = 0;   public var Y:int = 0;
          public var Y_SPEED:int = 5;
          public var DEPTH:int = 9;
          public var CONTAINER:Sprite = new Sprite();
          public function CREATE(CONTAINER:Sprite,X:int,Y:int):void
          {
              this.CONTAINER = CONTAINER;
              CONTAINER.stage.addEventListener(Event.ENTER_FRAME,STEP);
              this.X = X;     this.Y = Y;
              DRAW();
          }
          public function STEP(event:Event):void
          {
              this.graphics.clear();
              Y -= Y_SPEED;
              if (Y &lt; 20) {Y = 300; CONTAINER.removeChild(this); CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,STEP); CONTAINER.(delete this); CONTAINER = null; return;}
              DRAW();
          }
          public function DRAW():void 
          {
              this.graphics.beginFill(0xCCCC00,1);
              this.graphics.drawRect(X - 2,Y - 2,4,4);
              this.graphics.endFill();
              CONTAINER.addChild(this);
          }
      }
  }
  </code></pre>
  
  <p>The part I'm concerned about is in the STEP function when it checks to see if Y &lt; 20. You'll notice that it does several things afterwords. Am I deleting it correctly? If so is there anything I am doing to delete it that I don't need to?</p>