I'm still struggling a bit to wrap my head around local and global variables and how they work. I'm getting better with this, but here's one question I have:
In AS3, if I declare a variable inside of a function then I know that it isn't going to be available to the rest of the class:
1 2 3 | public function doSomething():void { var onlyHere:String = new String("inaccessible outside function"); } |
If onlyHereToo was a global variable, then yes it is accessible from outside the function. It would be accessible throughout your application.
Local var is easy to understand. Global var is a bit confusing, between _G and without _G. Take a look at this thread for the answer.
https://developer.anscamobile.com/forum/2011/11/14/difference-between-global-variables-gvar-and-var