I'd appreciate it if someone could debug the following code; I'm trying to move around a MovieClip (namely, "Ship") with the arrow keys, but when I test the .fla, nothing happens.
Easy stuff, and I've done it before, but the script isn't working and I can't see anything wrong with it.
class Ship extends MovieClip
{
var velocity;
var velRight;
var velLeft;
var velUp;
var velDown;
function onLoad()
{
velocity = 10;
velRight = 0;
velLeft = 0;
velUp = 0;
velDown = 0;
}
function onEnterFrame()
{
if(Key.isDown(Key.RIGHT))
{
_x += velocity;
velLeft = 0;
if(velRight < 10)
{
velRight += 1;
}
else(_x += velRight , velRight -= 1)
}
if(Key.isDown(Key.LEFT))
{
_x -= velocity;
velRight = 0;
if(velLeft < 10)
{
velLeft += 1;
}
else(_x -= velLeft , velLeft -= 1)
}
if(Key.isDown(Key.UP))
{
_y -= velocity;
velDown = 0;
if(velUp < 10)
{
velUp += 1;
}
else(_y -= velUp , velUp -= 1)
}
if(Key.isDown(Key.DOWN))
{
_y += velocity;
velUp = 0;
if(velDown < 10)
{
velDown += 1;
}
else(_y += velDown , velDown -= 1)
}
}
}
Apologies for the eye-burning wall of text, it's been ages since I posted here and I don't remember how to quote.