Hello all,
Recently I’ve been experimenting with taking values from a simple php file and displaying it in a dynamic text box whilst returning a value back into the database.
So far I have this.
dynamic class scripts.actionScript.enginCode extends MovieClip {
var carOneManufacture:String;
function enginCode(){
carOne = new LoadVars();
carOne.load("http://localhost/cargame/scripts/php/carOne.php");
carOne.onLoad = function(carStats){
carOneManufacture = this.manufacture
_root.textMovie.dynamicTextOne = carOneManufacture;
}
}
}
Which works great and all but second I attempt to trace carOneManufacture outside of the carOne.onLoad = function(carStats) it comes back with undefined.
Which has just straight up confused me, why is the variables have been loaded and work. Not work outside the onLoad function?
Thanks in advance
Sigs
Update
Whoops Two hours of trial and error and I’ve sorted it! Sorry for any time wasted thread can be closed now.
Final code:
dynamic class scripts.actionScript.enginCode extends MovieClip {
var carOne:Object;
var carOnePhp:LoadVars;
function enginCode(){
carOneUpdate()
}
function carOneUpdate(){
carOnePhp = new LoadVars();
carOnePhp.load("http://localhost/cargame/scripts/php/carOne.php?id=1");
}
function onEnterFrame(){
carCreator()
}
function carCreator(){
carOne = new Object();
carOne.make = carOnePhp.make;
carOne.cost = carOnePhp.cost;
carOne.bhp = carOnePhp.bhp;
carOne.handling = carOnePhp.handling;
carOne.weight = carOnePhp.weight;
carOne.reliability = carOnePhp.reliability;
carOne.aerodynamics = carOnePhp.aerodynamics;
}
}