Dynamically assembling MC names [AS1]

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 mNumber_mc (eg. m1_mc, m2_mc, m3_mc, etc…) I try to assemble the names in this way:


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,


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


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"];

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.