I recently spent an hour locating a resource leak source. It was caused by an undeclared member variable. I mistakenly assumed that AS3 would show a compile error when an undeclared variable is used. Is this a shortcoming of AS3 or is there some way to enable this type of error checking?
What was the nature of the resource leak? I find that Flash sometimes cares about this and sometimes doesn't (I suspect it has to do with the way the parent Class is defined, but haven't pinned this down). My current theory is that when your Class that doesn't declare the instances is the Base Class (and not the Class itself), then when Flash generates the Class for you it will also declare the instance variables in many, but not all, cases. One case I have seen where it did not do this was the instances themselves were fl.controls.RadioButton. Those things are sort of wonky anyway, so it's hard to say if Flash Components are the cause or the fact that the instances declare their Class in the Class field and not the BaseClass field, or if there was something completely unrelated.
That's the problem with pushing Flash in directions the Adobe engineers weren't directly expecting--most stuff like this is completely undocumented and you have to figure it out for yourself.
I quite often have undeclared variables (when I'm using the name of the instance to figure out what piece of data to populate the instance with, for example, but don't otherwise care about those instances), so if I'm likely to create memory leaks, it would be good to know this.
If you do figure it out, please blog it
Europe, Middle East and Africa