Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to compose a an array-name out of a string variable?

Status
Not open for further replies.

Oberon20

Technical User
Dec 27, 2002
1
NL
this is the code i'm using.. now, im not a pro.. (hence why i ask u folk) im just fooling around in flash to become a pro sometime in the future, but im having trouble getting flash to compose an array (or variable) name from a string. I hope u can help..


Elf = new Array (1,5,5,5,1,1,20);
Dwarf = new Array (5,20,10,5,1,10,10);

battle = new Array()
for(i=1; i<=7; i++){
battle = battle.concat(&quot;Elf&quot;);
}
// trace(battle.length);
for(i=1; i<=5; i++){
battle = battle.concat(&quot;Dwarf&quot;);
}
// trace(battle.length);
for(i=1; i<=6; i++){
battle = battle.concat(&quot;Elf&quot;);
}
// trace(battle.length);

trace(Elf);
trace(Dwarf);
trace(battle);



battlevar=0;
creaturevar=0;
trace(battle[0])


for(i=0; i<=battle.length; i++){
for(j=0; j<=battle[6]; j++){
creature&quot;creaturevar&quot; = new Array();
creature&quot;creaturevar&quot; = creature&quot;creaturevar&quot;.push(battle[battlevar]);
trace(creature&quot;creaturevar&quot;);
creaturevar++;
}
battlevar++;
}

stop ();

as i said, im no pro, so it could be full of other mistakes, but the string-to-(part of an)-array thingie is where im going wrong atm.. my experience is, if it doesnt allready work in fhe first place, there's got to be a way around it, but im not seeing it atm :-thx in advance for any help..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top