I have custom class that extends UIComponent which I use for putting
graphics on to the stage (I add them as children of a seperate UIComponent).
In the constructor I create a Timer and watch for the TIMER_COMPLETE event,
at which point I want the graphic to dissapear, which I do by setting alpha
= 0.
However, I am concerned that it will not be garbage collected, and I could
end up with quite a few of these, which may be bad for memory.
Question: Can i get the object to delete itself? (or atleast be in a state
suitable for grabage collection)
e.g. this.selfDestruct() ;)
The relevant code is shown below.
thanks
tom
*
public* *class* DrawingTool *extends* UIComponent
{
*private* *var* lifeTimer:Timer = *new* Timer(8000,1);
*public* *function* DrawingTool():*void*{
*super*();
lifeTimer.addEventListener(TimerEvent.TIMER_COMPLETE,onLifeTimer);
lifeTimer.start();
}
*private* *function* onLifeTimer(e:Event):*void*{
*this*.alpha = 0
*trace*(*">>>time out"*);
}
}