A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Movement with speed control

  1. #1
    Junior Member
    Join Date
    Apr 2004
    Posts
    12

    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 Attached Files
    BILLYBOB

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    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.

  3. #3
    Junior Member
    Join Date
    Apr 2004
    Posts
    12
    Does everybody in the forums give answer like this?
    Man! Soooo helpful.
    Thanks!
    BILLYBOB

  4. #4
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    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

  5. #5
    Junior Member
    Join Date
    Apr 2004
    Posts
    12
    LOL
    BILLYBOB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center