Copy link to clipboard
Copied
I am working on an airplane demo with lots of variables/ data which is growing quickly. And as the demo has grown it is become unweildy workign with variable/ data. So I am workign to create a plane demo with somewhat workign guages. As user goes through project, questions - answers change the plane guage settings. I currenly just have variables in name value pairs and basic functions switching values on guages.
I want to simplify staorage of variables. And functions to change the variables/ data. One thing to mention, some variables on the guages are shared on other guages, like altitude is on three guages. Also as the user goes through questions and makes changes. Not all the data is changed. A question may change a handful of variables.
Any recomendations on setup. A reference on a setup. I was thinking an array for data. And a loop for the questions to call function changing certain variables.
setObj("altitude",16700);
setObj("throttle", 450);
altitude.text=getObj("altitude");
throttle.text=getObj("throttle");
Copy link to clipboard
Copied
use a javascript object:
///// begin setup //////
const dataObj = {};
function setObj(key,value){
dataObj[key] = value;
}
function getObj(key){
return dataObj[key];
}
///// end setup //////
// usage
setObj("altitude",10000); // assign a key
getObj("altitude"); // retrieve value
Copy link to clipboard
Copied
This is helpful direction. I have an array of information. I am having trouble getting the array information into specific text fields on the stage or movie clips.
planeArray = Altitude "16700", Throttle "450"
then
altitude.text = 16700
trottle.text = 450
Copy link to clipboard
Copied
setObj("altitude",16700);
setObj("throttle", 450);
altitude.text=getObj("altitude");
throttle.text=getObj("throttle");