1 Reply Latest reply on Mar 24, 2011 8:24 PM by Flex harUI

    Class auto-delete itself

    flashzoollii

      Hi,

       

      Is it possible to create a class that it delete itself ?

       

      example :

       

      package com.arc.composants.profil_contact.scripts
      {
          import flash.events.EventDispatcher;
          import flash.events.IEventDispatcher;
         
          import mx.events.EffectEvent;
         
          import spark.effects.Move;
         
          public class Bouge extends EventDispatcher
          {
             
              public var ss:*;
              public var yFrom:int;
              public var yTo:int;
              private var k:Move;
             
             
              public function Bouge(target:IEventDispatcher=null)
              {
                  super(target);
              }
             
              public function go():void{
                  k = new Move();
                  k.yFrom = this.yFrom;
                  k.yTo=this.yTo;
                  k.duration=500;
                  k.target=ss;
                  k.play();
                 
                  k.addEventListener(EffectEvent.EFFECT_END, finit);
              }

       

              public function finit(e:EffectEvent):void
              {
                  k.removeEventListener(EffectEvent.EFFECT_END, finit);
                  k=null;
                  delete this; // not shure ????
              }

       

             
          }
      }

       

      thank for your help !

       

      see you !

        • 1. Re: Class auto-delete itself
          Flex harUI Adobe Employee

          Actionscript uses a garbage collector.  As soon as nobody is referencing the

          instance, it is available for collection.  You don't actively delete things,

          just de-reference.  In other words, you don't burn the trash, you just put

          it out on the curb.

          1 person found this helpful