# Dynamically assembling MC names \[AS1\]

**URL:** <https://forum.kirupa.com/t/dynamically-assembling-mc-names-as1/118994>\
**Category:** Uncategorized\
**Created:** [August 10, 2004, 6:52pm UTC](https://forum.kirupa.com/t/dynamically-assembling-mc-names-as1/118994 "2004-08-10T18:52:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blue\_chi](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/blue_chi/32/62_2.png) [@blue\_chi](https://forum.kirupa.com/u/blue_chi)\
**Post date:** [August 10, 2004, 6:52pm UTC](https://forum.kirupa.com/t/dynamically-assembling-mc-names-as1/118994/1 "2004-08-10T18:52:55Z")

</div>

Hello people, I’m having a very weird problem and it would be nice if anyone can help.

I have a very simple function that attaches another MC from the library to another MC, the thing about the function is that it is supposed to attach the MC to many other MCs, my MCs are named _m **Number** \_mc_ (eg. m1\_mc, m2\_mc, m3\_mc, etc…) I try to assemble the names in this way:

```php

function Flashing() {
	variable = "m"+current+"_mc";
	variable.attachMovie("alp_mc", "alp_mc", 1);
	_root.current++;
	if (current > mc_total){
		current = 0;
	}

```

… and IT DOESN’T WORK!

There was nothing with my variables at all, I tried this and it didn’t work,

```php

function Flashing() {
	variable = "m1_mc";
	variable.attachMovie("alp_mc", "alp_mc", 1);
	_root.current++;
	if (current > mc_total){
		current = 0;
	}

```

I then tried this and it worked :S

```php

function Flashing() {
	variable = m1_mc;
	variable.attachMovie("alp_mc", "alp_mc", 1);
	_root.current++;
	if (current > mc_total){
		current = 0;
	}

```

What I realised is that I cannot give my instance name as a basic string. It has to be written directly without the quotation marks. I really don’t know how to make it work, the only thing that I managed to do is create an array with the whole listed TYPED down without the quotation marks, this is crazy, can somebody please help me.

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [August 10, 2004, 7:18pm UTC](https://forum.kirupa.com/t/dynamically-assembling-mc-names-as1/118994/2 "2004-08-10T19:18:37Z")

</div>

> [@blue\_chi](#):
>
> Hello people, I’m having a very weird problem and it would be nice if anyone can help.
> 
> I have a very simple function that attaches another MC from the library to another MC, the thing about the function is that it is supposed to attach the MC to many other MCs, my MCs are named _m **Number** \_mc_ (eg. m1\_mc, m2\_mc, m3\_mc, etc…) I try to assemble the names in this way:
> 
> ```php
> 
> function Flashing() {
> variable = "m"+current+"_mc";
> variable.attachMovie("alp_mc", "alp_mc", 1);
> _root.current++;
> if (current > mc_total){
> current = 0;
> }
> 
> ```
> 
> … and IT DOESN’T WORK!
> 
> There was nothing with my variables at all, I tried this and it didn’t work,
> 
> ```php
> 
> function Flashing() {
> variable = "m1_mc";
> variable.attachMovie("alp_mc", "alp_mc", 1);
> _root.current++;
> if (current > mc_total){
> current = 0;
> }
> 
> ```
> 
> I then tried this and it worked :S
> 
> ```php
> 
> function Flashing() {
> variable = m1_mc;
> variable.attachMovie("alp_mc", "alp_mc", 1);
> _root.current++;
> if (current > mc_total){
> current = 0;
> }
> 
> ```
> 
> What I realised is that I cannot give my instance name as a basic string. It has to be written directly without the quotation marks. I really don’t know how to make it work, the only thing that I managed to do is create an array with the whole listed TYPED down without the quotation marks, this is crazy, can somebody please help me.

try variable = \_root[“m”+current+“\_mc”];

---

<div class="post-metadata">

**Author:** ![blue\_chi](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/blue_chi/32/62_2.png) [@blue\_chi](https://forum.kirupa.com/u/blue_chi)\
**Post date:** [August 10, 2004, 7:24pm UTC](https://forum.kirupa.com/t/dynamically-assembling-mc-names-as1/118994/3 "2004-08-10T19:24:11Z")

</div>

It actually worked! I tried doing some weird stuff with \_root and with the brackets, but I didn’t try to do it this way. Can someone please explain to me why this method works while the other ways don’t.
