Oops that mas my fault there, you see in the part when it's going up, and left. Try changeing the "min" with the "max"
Heres the whole code again with the glitch fixed:
onClipEvent (load) {
this.speed = 0;
this.accel = 0.5;
this.maxspeed = 5;
this.minspeed = 0.5;
this.decel = 0.8;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
xspeed += accel;
xspeed = Math.max(xspeed, minspeed);
xspeed = Math.min(xspeed, maxspeed);
}
if (Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT)) {
xspeed -= accel;
xspeed = Math.min(xspeed, -minspeed);
xspeed = Math.max(xspeed, -maxspeed);
}
if (Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)) {
yspeed -= accel;
yspeed = Math.min(yspeed, -minspeed);
yspeed = Math.max(yspeed, -maxspeed);
}
if (Key.isDown(Key.DOWN) && !Key.isDown(Key.UP)) {
yspeed += accel;
yspeed = Math.max(yspeed, minspeed);
yspeed = Math.min(yspeed, maxspeed);
}
if (!Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) {
xspeed *= decel;
}
if (!Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)) {
yspeed *= decel;
}
_y += yspeed;
_x += xspeed;
}
The !key.isdowns need to be separated for the _x and _y. Otherwise if you hold down one button after going diagonal, you still go diagonal.....
I think this should work. Sorry if it doesn't.