Hi there,
I just had a curious thought and wondered if anyone knew if this is possible, if I had three buttons with the following functions:
first_btn.addEventListener(MouseEvent.MOUSE_UP,firstButton);
function firstButton(event:MouseEvent){
trace("button 1");
}
second_btn.addEventListener(MouseEvent.MOUSE_UP,secondButton);
function secondButton(event:MouseEvent){
trace("button 2");
}
third_btn.addEventListener(MouseEvent.MOUSE_UP,thirdButton);
function thirdButton(event:MouseEvent){
trace("button 3");
}
Now this feels like a lot of repetitive functions so I was wondering if there was a way to add arguments to button functions e.g. something like this:
first_btn.addEventListener(MouseEvent.MOUSE_UP,buttonPressed(1));
second_btn.addEventListener(MouseEvent.MOUSE_UP,buttonPressed(2));
third_btn.addEventListener(MouseEvent.MOUSE_UP,buttonPressed(3));
function buttonPressed(event:MouseEvent, buttonNumber){
trace("button " + buttonNumber);
}
Any ideas how to go about doing this?
Cheers
Bob