flashmad
unread,Dec 13, 2009, 11:05:10 AM12/13/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ActionScript User Interface Development
Here is a small trick to avoid writing multiple click events for your
buttons in as 3.0 flash projects.
You will need to follow the naming of buttons as follows [b_1 , b_2 or
btn_1, btn_2,... etc]. Now watch the code i use (assume i have 9
buttons]
for(var i=1;i<10;i++){
this["b_"+i].addEventListener(MouseEvent.CLICK,clicked);
}
function clicked(e:Event){
trace(e.target.name.split(”_”)[1]);
}
This will trace the end number of buttons [1,2,3...etc]. That means
you can differentiate each click. Using gotoAndStop(e.target.name.split
(”_”)[1]) or what ever you like will do the trick.