flash: why use "var"?
flash: why use "var"?
Out of context: Reply #3
- Started
- Last post
- 13 Responses
- kpl0
var is more useful in blocks. if you have a bunch of variables in a block (ie, a function) that are not needed outside of it, declaring variables with var within that block means those variables will clear the memory once the block is finished.
ie, in
if (1) {
var blah ="blah blah";
}trace (blah);
result: blah is undefined
it's useful when you don't want certain variables hogging memory all the time.
admittedly, in real small scripts it doesn't make a whole lot of difference.