• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Advice for variables, data in Animate - Canvas

Community Beginner ,
Dec 13, 2021 Dec 13, 2021

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.

 

Views

129

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 14, 2021 Dec 14, 2021

setObj("altitude",16700);

setObj("throttle", 450);

 

altitude.text=getObj("altitude");

throttle.text=getObj("throttle");

Votes

Translate

Translate
Community Expert ,
Dec 14, 2021 Dec 14, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2021 Dec 14, 2021

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 14, 2021 Dec 14, 2021

Copy link to clipboard

Copied

LATEST

setObj("altitude",16700);

setObj("throttle", 450);

 

altitude.text=getObj("altitude");

throttle.text=getObj("throttle");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines