Need help: acces multiple elements dynamically by a for() problem (AS != JS)

I wanna acces multiple elements onEnterFrame by a for()

I just dunno how to. barXX_mc cannot be a var like in JavaScript (var barXX_mc = “bar0”+i+"_mc"). I am new to Flash and wonder how to do this :h:

Can somebody help me? If you need the *.fla contact me by alexander(at)dom.de

regards
Alex

/*	for(i = 0; i < bars; i++) {
		barXX_mc = ; // <-- ??? = "bar0"+i+"_mc" does not work, = bar01_mc is static *erks*
		barXX_mc._x = space + Math.sin(rad + (0.5 + i / (bars - 1)) * Math.PI) * amp;
	}*/

// The following should be replaced by the for() above
	
	bar00_mc._x = space + Math.sin(rad + 0.5 * Math.PI) * amp;
	bar01_mc._x = space + Math.sin(rad + (0.5 + 1 / (bars - 1)) * Math.PI) * amp;
	bar02_mc._x = space + Math.sin(rad + (0.5 + 2 / (bars - 1)) * Math.PI) * amp;
	bar03_mc._x = space + Math.sin(rad + (0.5 + 3 / (bars - 1)) * Math.PI) * amp;
	bar04_mc._x = space + Math.sin(rad + (0.5 + 4 / (bars - 1)) * Math.PI) * amp;
	bar05_mc._x = space + Math.sin(rad + (0.5 + 5 / (bars - 1)) * Math.PI) * amp;
	bar06_mc._x = space + Math.sin(rad + (0.5 + 6 / (bars - 1)) * Math.PI) * amp;
	bar07_mc._x = space + Math.sin(rad + (0.5 + 7 / (bars - 1)) * Math.PI) * amp;
	bar08_mc._x = space + Math.sin(rad + (0.5 + 8 / (bars - 1)) * Math.PI) * amp;
	bar09_mc._x = space + Math.sin(rad + (0.5 + 9 / (bars - 1)) * Math.PI) * amp;
	bar10_mc._x = space + Math.sin(rad + (0.5 + 10 / (bars - 1)) * Math.PI) * amp;
	bar11_mc._x = space + Math.sin(rad + 1.5 * Math.PI) * amp;

Hi, the problem is that that the value of your variable is a string.

Providing that instances of your objectc (symbol) exist in the timeline you’re refering to simply make flash evaluate the string on your variable.:

[AS]
for (i=0; i<bars; i++) {
if (i<10) {
var num =“0”+i;
} else {
var num = i;
}
var barXX_mc = eval(“this.bar”+num+"_mc");
barXX_mc._x = space+Math.sin(rad+(0.5+i/(bars-1))*Math.PI)*amp;
}

[/AS]

SHO

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12082

thx eki and seno!

Any time :}