here is my code:
var sp:Sprite = new Sprite();
sp.x = sp.y = 40;
addChild(sp);
for (var i:int = 0; i < 5; i++){
var btn:MovieClip = new Button();
btn.name = "btn" + i;
btn.x = 0;
btn.y = i* (btn.height + 3);
btn.addEventListener(MouseEvent.MOUSE_OVER, onOver);
btn.addEventListener(MouseEvent.MOUSE_OUT, onOut);
btn0.addEventListener(MouseEvent.MOUSE_UP, onUp);// NOT WORKING, UNDEFINED PROPERTY btn0
sp.addChild(btn);
}
function onOver(e:MouseEvent):void{
e.currentTarget.alpha = .5;
}
function onOut(e:MouseEvent):void{
e.currentTarget.alpha = 1;
}
function onUp(e:MouseEvent):void{
e.currentTarget.x += 4;
}
I want different actions for different MCs, but I can’t access my MCs. I gave them names btn.name = “btn” + i;, but whenever I tried using MCs instance name “btn0” or “btn1” and so on it didn’t work. So what is an instance names for my MCs?