This content has been marked as final. Show 3 replies
local vars are always better than global vars, imho, maybe not in regards to the memory used, but in general. It might depend on the stuff you are doing what's better; personally, I try to avoid using globals.
Variables in MCs are removed too when the MC gets removed, whereas global vars would remain until the player is closed, I guess. Flash has a garbage collector that removes local variables after use, so when you use vars local to functions, they should be deleted automatically when the function finishs. You can also use the 'delete' statement to remove vars that are not used anymore. To remove all variables in an MC without removing the MC itself, you can use the attached code. Note that it removes also the $version var, if it's present.
nice bit of code I wouldnt have thought of that
Also, remember that if your using an onEnterFrame event that it will run continuously until you stop it, thus using processor power.
consider deleting within the function using it