addEventlistener, array, as linkage
i have added 10 movieclips linkage "box" in function. i've named different instances "layer1" "layer10"
my question is, how can 1 add eventlistener to, lets say, "layer4"?
var num_boxes:int = 10;
var box_spacing:int = 1;
var _boxes:array = [];
function test()
{
for (var i:int = 0; < num_boxes; i++)
{
var box:box = new box( + 1 );
box.y = (box.height + box_spacing) * i;
box.name= "layer" +( + 1);
box.buttonmode = true;
box.addeventlistener( mouseevent.mouse_down, onboxpress );
box.addeventlistener( mouseevent.mouse_up, onboxrelease );
addchild( box );
_boxes.push( box );
}
you put in conditional checks if " " == 3 , when add event listener current box
More discussions in ActionScript 3
adobe
Comments
Post a Comment