Hours of fun with ‘Nudge the Black Circle’
Monday 28 September 2009 - Filed under Actionscript/Flash
An EventListener listen for clicks for each of the four buttons, executing the corresponding function, which manipulates the X or Y value by 10. Is there a more efficient way to do this?
btn_left.addEventListener(MouseEvent.CLICK, nudge_left);
btn_right.addEventListener(MouseEvent.CLICK, nudge_right);
btn_up.addEventListener(MouseEvent.CLICK, nudge_up);
btn_down.addEventListener(MouseEvent.CLICK, nudge_down);
function nudge_left(e:MouseEvent):void{
black_circle.x -= 10;
}
function nudge_right(e:MouseEvent):void{
black_circle.x += 10;
}
function nudge_up(e:MouseEvent):void{
black_circle.y -= 10;
}
function nudge_down(e:MouseEvent):void{
black_circle.y += 10;
}
2009-09-28 » Asgeir