PDA

View Full Version : Accessing clips I attached?



geoken
May 15th, 2007, 11:43 PM
Ok, I'm guessing there is an easy answer here but I can't figure it out.

I'm attaching a bunch of clips like this; (mainBut is the name of the class)

for (var i = 0; i<buttons.length; i++) {

var mc = "b"+i;

mc = new mainBut;
mc.tex.text = buttons[i];
mc.x = pos;
mc.y = -30;
addChild(mc);

}



So now how do I control the clips I've made? Say, for example, a button is supposed to tween one of the clips alpha's to zero, how would I adress the clip. I tried b0 and it didn't work. I hard partial success by pointing my button at 'mc' but that obviously only allows me to control the last button.

designcliche
May 16th, 2007, 04:55 AM
Put them into an array, you can access them that way.

geoken
May 16th, 2007, 07:11 AM
Put them into an array, you can access them that way.

What do you mean?

geoken
May 16th, 2007, 06:34 PM
I've achieved my desired result but I can't help but think I'm doing it the wrong way.

Basically I create the mc's

for (var i = 0; i<10; i++) {

var mc = "b"+i; //I've tried this multiple ways (this["b"+i], ["b"+i]) and they all gave me the same result

mc = new mainBut;
mc.name = "z"+i;
addChild(mc);
}

Then when I want to access the clip I use getChildByName() or getChildAt(). I'm assuming there is a better way to do this.