title: Removing Tween For Garbage Collection in AS3
body: <p>I'm trying to remove a <code>tween</code> object after it has complete so the memory can be freed by garbage collection.</p>
  
  <p>In this example I'm passing the <code>fadeIn</code> function a <code>UILoader</code> object that is cast as a sprite so that it fades in when it is finished loading.  When the <code>tween</code> finishes animating, I want to remove the <code>tween</code> object.  I've included the compiler errors as comments.</p>
  
  <pre><code>function fadeIn(e:Sprite):void
  {
    var myTween:Tween = new Tween(e, "alpha", None.easeNone, 0.0, 1.0, 0.2, true);
    myTween.addEventListener(Event.COMPLETE, deallocateObject, false, 0, true);
  }
  
  function deallocateObject(e:Event):void
  {
    //delete(e.currentTarget); //Warning: 3600: The declared property currentTarget cannot be deleted. To free associated memory, set its value to null.
    e.currentTarget = null; //1059:Property is read-only.
  }
  </code></pre>