I was doing the actionscript tutorial with the beetle and using key’s to make it move in different directions. And I thought I’d try to add some acceleration to it. Well, the only way i knew how to do that was to make the movement exponential instead of just linear. I wrote this code myself, and well I’m a total n00b at actionscript, so sorry if its hideous. Here is what I wrote:
If (this._y < -1)
{
on (keyPress “<Up>”) {
currentY = this._y;
this._y = currentY + .1 * currentY;
_root.bug._rotation = 360;
}
on (keyPress “<Down>”) {
currentY = this._y;
this._y = currentY - .1 * currentY;
_root.bug._rotation = 180;
}
}
I thought I’d need to make it exponential only when the y was >, < 1, so that it wouldn’t exponentialy increase 0 (stay at 0). Yet, it gives me some hideous looking error.
Scene=Scene 1, Layer=beetle, Frame=1: Line 26: Statement must appear within on handler
{
Scene=Scene 1, Layer=beetle, Frame=1: Line 39: ‘)’ or ‘,’ expected
Scene=Scene 1, Layer=beetle, Frame=1: Line 38: Statement must appear within on handler
If (this._y
I know this method would work fairly wierd after the bug stopped moving at like x = 90, and then the key was pressed again and it starts off moving very fast. But, i couldn’t get the actual acceleration tutorial to work. Thanks for all your help guys.
Cheers,
NaliWarCowz :trout: