Content

Visual communicator / logbook & brain bin

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):voi
d{
black_circle.x += 10;
}
function nudge_up(e:MouseEvent):void{
black_circle.y -= 10;
}
function nudge_down(e:MouseEvent):void{
black_circle.y += 10;
}

Tagged: » »

2009-09-28  »  Asgeir

Share your thoughts

Re: Hours of fun with ‘Nudge the Black Circle’







Tags you can use (optional):
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>