Name: loadGlobalVars [MX] - loads variables into the _global object
Author: senocular: www.senocular.com
Date: 1899-12-31T00:39:51.500
Documentation:
LOADGLOBALVARS: loads variables from a text file into
the _global object so that they are... global ;)
Arguments:
- url: the url from which the variables are loaded
- onLoad: the onLoad function to be called when the variables are loaded
- noOverWrite: (optional) boolean determining whether the loaded variables should, if they
already exist in _global should be overwritten with the new values or not. Default: false
meaning that they will be overwritten.
Returns:
- nothing
Example:
function done(){
for(var a in _global) trace(a +": "+ _global[a]);
}
_global.var1 = "keepme"
loadGlobalVars("vars.txt",done,1); // vars.txt = var1=true&var2=false&var3=nothing
// output
// var2: false
// var3: nothing
// var1: keepme
1
2
3
4
5
6
7
8
9
10
11
12
13
_global.loadGlobalVars = function(url,onLoad,noOverWrite){
var glv = new LoadVars();
glv.onLoad = function(success){
delete this.onLoad;
for (var v in this){
if (noOverWrite && _global[v] !== undefined) continue;
_global[v] = this[v];
}
onLoad(success);
}
glv.load(url);
}
ASSetPropFlags(_global,"loadGlobalVars",1,1);