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

**URL:** <https://forum.kirupa.com/t/need-help-acces-multiple-elements-dynamically-by-a-for-problem-as-js/101482>\
**Category:** Uncategorized\
**Created:** [February 10, 2004, 11:19am UTC](https://forum.kirupa.com/t/need-help-acces-multiple-elements-dynamically-by-a-for-problem-as-js/101482 "2004-02-10T11:19:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_4\_Cologne](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Alex\_4\_Cologne](https://forum.kirupa.com/u/Alex_4_Cologne)\
**Post date:** [February 10, 2004, 11:19am UTC](https://forum.kirupa.com/t/need-help-acces-multiple-elements-dynamically-by-a-for-problem-as-js/101482/1 "2004-02-10T11:19:32Z")

</div>

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](http://dom.de)

regards  
Alex

```php
/*	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;

```
