Groups | Blog | Home
all groups > flash actionscript > february 2004 >

flash actionscript : CreateEmptyMovice clip and Generating Buttons.


userid
2/27/2004 10:13:30 PM
Hi,

I need to create x amount of buttons depending on the number of values in an
array. (Trying to make a paginator actually). I can create the movieclips just
fine, but I need to be able to have each one clickable to go to a new value in
the array.

Adding a press action simply returns the final value of i in my for loop. Any
help would be appreciated:

for (j=0; j<page_01_array.length; j++){
nm2 = "button"+j;
_root.createEmptyMovieClip(nm2,0);
_root[nm2].alpha = 0;
_root[nm2]._x = n2
_root[nm2]._width = 20;
_root[nm2]._height = 20;
n2 = n2+20;
_root[nm2].onmousedown = function() {
trace("you pressed" _root[nm2]._name);
}
}
Jack.
2/27/2004 10:56:18 PM
you need to fill the empty clip (then set alpha),

page_01_array = [0,1,2,3,4,5,6,7,8,9];
square = [20,20];

for(j=0; j != page_01_array.length; j++){
nm2 = "button"+j;
ref = this.createEmptyMovieClip(nm2,n2);
with(ref){
lineStyle(1,0x000000,100);
beginFill(0xFFFFFF);
lineTo(square[0],0);
lineTo(square[0],square[1]);
lineTo(0,square[1]);
lineTo(0,0);
endFill();
ref._x = n2;
//ref.alpha = 0;
}
n2 += 22;
pressed(ref);
}

function pressed(ref){
trace(ref);
ref.onPress = function(){
trace("you pressed "+ref._name);
}
};

hth
AddThis Social Bookmark Button