Movement with speed control
How would I create car movements with speed control?
I tried following THIS Tutorial. But when I play the movie/game, it only rotates my car. It wont go forward.
I have my Fla.
Attached Files
Senior Member
Your problem is that the speed variable was never initialized. Add this to the top of your script to fix it.
code:
onClipEvent(load)
{
speed =0 ;
}
I diagnosed this by adding a trace statement to your existing code:
trace(speed);
I saw this in the output window:
NaN
NaN
NaN
NaN
NaN
...
'NaN' means 'not a number' and it meant that something about the speed calculation involved a non-numeric variable.
Since the speed variable was undefined, and all the calculations on it referred to it, they were all invalid and producing a NaN result.
In other words, if x is undefined then "x + 2" is also undefined.
Does everybody in the forums give answer like this?
Man! Soooo helpful.
Thanks!
Senior Member
Some of us do, yes. I tend to write very, uh, complete answers when I've had too much coffee.
You can thank the Starbucks establishment
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width