Not very clear, poor coding.
You could've made it A LOT clearer, and the scripts were terrible.
_root.score = _root.score+1;
Could've been shortened to:
score++;
If the button was within a movie clip, then you would've needed to have the _root prefix, but seeing as it should be within the main timeline, that's all you would've needed to type.
Secondly, I find startDrag tends not to work well. Instead, you should use this:
onClipEvent (enterFrame) {
_x = _parent._xmouse;
_y = _parent._ymouse;
}
And what's with the 'eq' operator? That was deprecated in Flash 4, I believe. == Works just as well with strings, as well as working on booleans and values, too.
Why would you want to have a car that can strafe. To make a steering car, you would use a script a bit more like this:
onClipEvent (enterFrame) {
// When key UP is pressed, speed is increased
if (Key.isDown(Key.UP)) {
speed += 3;
} else {
// When key DOWN is pressed, speed is decreased
if (Key.isDown(Key.DOWN)) {
speed -= 1;
} else {
// If UP or DOWN aren't pressed then the speed decreases
speed *= .9;
}
}
// The car will start to slow down after the speed of 25
if (Math.abs(speed)>25) {
speed *= .5;
}
// Turns the car left
if (Key.isDown(Key.LEFT)) {
_rotation -= speed;
}
// Turns the car right
if (Key.isDown(Key.RIGHT)) {
_rotation += speed;
}
// Moves the car
speed *= .8;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.move.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.3;
}
}
And if you wanted something that strafed like the one you wrote, why not use one variable to control the speeds in all directions? Like so:
onClipEvent (load) {
speed = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_x += speed;
} else if (Key.isDown(Key.LEFT)) {
_x -= speed;
}
if (Key.isDown(Key.UP)) {
_y -= speed;
} else if (Key.isDown(Key.DOWN)) {
_y += speed;
}
}
You seem to be compelled to use statements such as:
_y = _y + 10;
Why not just shorten it to:
_y += 10;
I hope you learned something from that little lecture.