Hey again Kirupians,
Is there any way to shorten this code by passing parameters to the eventhandler through the addeventlistener?
For example, this is the code:
upBtn.addEventListener(MouseEvent.MOUSE_UP, goUp)
downBtn.addEventListener(MouseEvent.MOUSE_UP, goDown)
function goUp(e:MouseEvent):void{
makeChange("up")
}
function goDown(e:MouseEvent):void{
makeChange("down")
}
function makeChange(msg):void{
trace (msg)// up if up pressed, down if down pressed
}
Is there some sort of way to do:
upBtn.addEventListener(MouseEvent.MOUSE_UP, makeChange(up))
downBtn.addEventListener(MouseEvent.MOUSE_UP, makeChange(down))
function makeChange(msg):void{
trace (msg)// up if up pressed, down if down pressed
}
Basically, just pass the params to the handler through the listener… I hope there is, this is getting tedious…
Cheers!