[osflash] Delete Class (theNinjaBunny SuperHero)

David Rorex drorex at gmail.com
Fri Apr 14 18:02:56 EDT 2006


I don't think "delete this;" is legal. "delete" deletes references, it
doesn't actually mark the object for deletion. It doesn't make sense
to delete the 'this' reference.

///////
// some example code
var obj1 = {name:"bob"};
var obj2 = obj1; // obj2 and obj1 are both references to the same object

obj2.name = "Jack"; // this will change the object

// proof that there is only a single object
trace(obj1.name); // Jack
trace(obj2.name); // Jack

delete obj1;
// .. wait or delay as long as you like ...
trace(obj2.name); // Jack -- the object was never deleted, only the reference
/////////////////////

To delete an object (not a movieclip), you simply need to delete all
the references to it. So, if the only reference is in an array, just
remove that element from the array.

Hope this helps,
-David R

On 4/13/06, Steve Mathews <happydog at gmail.com> wrote:
> The garbage collector will delete when it "feels" like it. All calling
> delete does is mark it for clean up.
>
> On 4/13/06, theNinjaBunny SuperHero <nodani at gmail.com> wrote:
> > Yes, it's on a class (no extends Objects, neither MovieClip)
> >
> > Tracing the object after "deleting" it,
> > return me the object with all its variables.
> >
> > class ScrollObject {
> >
> > /*
> > some stuff
> > */
> >        public function removeObject():Void {
> >                delete this;
> >                C.log(this);
> >        };
> > };
> >
> > C.log is LuminicBox Logger.
> > That's return me the object, like "delete this" is not working.
> >
> > Thanks
> > _______________________________________________
> > osflash mailing list
> > osflash at osflash.org
> > http://osflash.org/mailman/listinfo/osflash_osflash.org
> >
> >
> >
>
> _______________________________________________
> osflash mailing list
> osflash at osflash.org
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>



More information about the osflash mailing list