Bug/Feature - De-Refrenced Variables in Flex (Double Instantiation)
I forgot to post about this earlier, but I discovered some interesting behavior in Flex when I accidentally instantiated a timer object twice.
I had a component with an init command that was called on creationComplete but I also accidentally called component.init() from the parent application. Inside my init function I had this:
timer=new Timer(1000,(parentApplication.TIMELIMIT*60));
timer.addEventListener(TimerEvent.TIMER,onTick);
timer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);
timer.start();
You would think that one init would happen, then the next would happen and the timer object would be re-instantiated since there is the "new" keyword. Not so in Flex (this was using 2.01).
The result is that when I stopped the timer using timer.stop(), only one instance stopped and onTimerComplete would still fire. The solution, obviously, is not to accidentally call the same function twice. But this just goes to show that it is possible to de-reference a variable in flex and have it floating around in memory (and it never gets garbage collected since it's still firing events).
