Is there method that gets called just before object destroyed? So I can override it.
Like
protected override function beforeDestuction():void
{
trace("This object is about to be destroyed!");
}
Is there method that gets called just before object destroyed? So I can override it.
Like
protected override function beforeDestuction():void
{
trace("This object is about to be destroyed!");
}
If by destroyed you mean getting garbage-collected, then I don't think there's an event or a Object method for that.
This won't apply to all objects, but when looking at components that extend UIComponent, the 'remove' event can be somewhat usefull, assuming there are no other strong references to a removed object it should be garbage collected.
One way to know whether an object will be garbage collected is to hold references in a Collection to all the objects that you allocate memory for. Then when you want the GC to destroy them, then take them out of the Collection. When you take them out of the collection, call your method "beforeGarbageCollection" or "beforeDestruction"; hopefully soon (but no guarantees) the GC will pick up the unreferenced object and destroy it.
Let me know if this is suitable.