Flash actionscript 3.0: how to get the keyboard event in action script 3.0

how to get the keyboard event in action script 3.0

Posted by Sankar.G | Posted in | Posted on 12:34 PM

you can able to get the ketboard event in action script 3.0
code:

parent.addEventListener(KeyboardEvent.KEY_DOWN.fun);
function fun(e:KeyboardEvent)
{
switch(e.keyCode)
{
case keyboard.RIGHT
movie_mc.x+=10;
break;
case keyboard.LEFT
movie_mc.x-=10;
break;
case keyboard.UP
movie_mc.y-=10;
break;
case keyboard.DOWN
movie_mc.y+=10;
break;
}
}
this is the way to get the keyboard Event using action script 3.0 movie_mc is a movie clip if you pressed the left button it will go to left side similarly to all side

Comments (0)