actionscript: global variables
actionscript: global variables
Out of context: Reply #5
- Started
- Last post
- 6 Responses
- st33d0
I've made a whole site based on this scoping issue.
The issue is that LoadVars cannot see outside itself - so you have to put a reference to the outside INSIDE LoadVars.
This becomes tricky when doing it in an AS2.0 class, you have to use ["thisCrap"] to trick the compiler into letting you define a variable that doesn't exist.
var fileName = "http://newstoday.com";
var myLoadVars = new LoadVars();
myLoadVars["MC"] = this;
myLoadVars.onLoad = function(success){
if(success){
trace(this["MC"].fileName);
}
}
myLoadVars.load(fileName);