Skip to content

Instantly share code, notes, and snippets.

@Olbergx
Created February 26, 2019 07:48
Show Gist options
  • Save Olbergx/add53a7966cb50c71b334e146ad01405 to your computer and use it in GitHub Desktop.
Save Olbergx/add53a7966cb50c71b334e146ad01405 to your computer and use it in GitHub Desktop.
import flash.events.KeyboardEvent;
stop();
stage.addEventListener(KeyboardEvent.KEY_DOWN, f_down);
var k:int = 1;
var n:int = 1;
function f_down (e:KeyboardEvent) {
//trace(e);
if (e.keyCode == Keyboard.RIGHT) {
if(k != 1)
{
mc.scaleX *= -1;
k=1;}
mc.x +=2;
}
if (e.keyCode == Keyboard.DOWN) {
if(n != 0)
{
mc.scaleY *= -1;
n=0;}
mc.y +=2;
}
if (e.keyCode == Keyboard.LEFT) {
if(k != 0)
{
mc.scaleX *= -1;
k=0;}
mc.x -=2;
}
if (e.keyCode == Keyboard.UP) {
if(n != 1 )
{
mc.scaleY *= -1;
n=1;}
mc.y -=2;
}
}mc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment