actionscript 3 - Creating variables in a systematical way using loops in AS3? -


is there? let's need 5 variables in actionscript 3.0 , name them follows:

var myvar_1 = "things"; var myvar_2 = "things"; var myvar_3 = "things"; var myvar_4 = "things"; var myvar_5 = "things"; 

but instead of having type them 1 1, work in loop? can't seem make work , love help/advice on matter.

yes, can create dynamic property name using [ ] array access:

var variables:object = {};  for(var i:int = 0; < 5; i++){     variables["myvar" + i] = "value " + i; }  trace(variables.myvar3); // "value 3" 

the variables object in case replaced dynamic object, including movieclips.

however, in cases store data index makes more sense use array. example:

var variables:array = []; for(var i:int = 0; < 5; i++){     variables.push("value " + i); }  trace(variables[3]); // "value 3" 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -