dcsimg
A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: ------------------------WTH- WHY doesnt this script work???(moving script for a car)

  1. #1
    Junior Member
    Join Date
    Feb 2001
    Posts
    16
    onClipEvent (enterFrame) {
    if (Key.isDown(39)) {
    setProperty(_root.auto, _rotation, getProperty(_root.auto, _rotation)+(speed/3));
    }
    if (Key.isDown(37)) {
    setProperty(_root.auto, _rotation, getProperty(_root.auto, _rotation)-(speed/3));
    }
    if (Key.isDown(38)) {
    if (Number(speed)<50) {
    speed = speed+15;
    }
    } else {
    if (Number(speed)>7) {
    speed = speed-8;
    } else {
    if (Number(speed)>0) {
    speed = speed-1;
    }
    }
    }
    if (Key.isDown(40)) {
    if (Number(speed)>30) {
    speed = speed-30;
    } else {
    speed = 0;
    }
    }
    setProperty(_root.auto, _x, getProperty(_root.auto, _x)+(Math.cos(_root.auto._rotation)*(speed/10)));
    setProperty(_root.auto, _y, getProperty(_root.auto, _y)+(Math.sin(_root.auto._rotation)*(speed/10)));
    }


    The last part shows the script for the movement calculated by the rotation of the car. but when i script it this way the rotation does not fit to the movement!
    I changed somethin in the last part:
    ...
    ...
    setProperty(_root.auto, _x, getProperty(_root.auto, _x)+(Math.cos(_root.auto._rotation/50)*(speed/10)));
    setProperty(_root.auto, _y, getProperty(_root.auto, _y)+(Math.sin(_root.auto._rotation/50)*(speed/10)));
    }

    the /50 made it work a bit, but the movement does not really fit!! why??????? dl the movie: http://www.myfav.de/pics/formel1.zip

    PLEASE ANSWER, THX

  2. #2
    Not PWD ViRGo_RK's Avatar
    Join Date
    May 2001
    Posts
    1,799

    Well,

    in Key.isDown (Key.40)

    "40" isn't a key, it's a number. You should have something like "UP", "DOWN", "RIGHT", "LEFT", "SHIFT", The list goes on and on.

  3. #3
    Junior Member
    Join Date
    Feb 2001
    Posts
    16
    Well thats workin fine because every key has a specific number. The thing I wrote up there was my only problem.
    Download the movie and u will see!
    OH it is:
    Key.isDown(40) and not Key.isDown(key.40)!!!!

  4. #4
    Junior Member
    Join Date
    Feb 2001
    Posts
    16
    PLEASE HELP ME!!!!!!!!!!!!!!!!!

  5. #5
    Not PWD ViRGo_RK's Avatar
    Join Date
    May 2001
    Posts
    1,799
    Well, once again, I show my miracules powers to make an ass of my self on something I don't know. :-D

  6. #6
    Junior Member
    Join Date
    Feb 2001
    Posts
    16

  7. #7
    Junior Member
    Join Date
    Feb 2001
    Posts
    16
    please help me!!!!!!!!!!!
    ISN'T here anybody who knows that?

  8. #8
    Not PWD ViRGo_RK's Avatar
    Join Date
    May 2001
    Posts
    1,799

    hmm...

    All I can say is that it is in your best intrest to take this to the actionscript section. If your blamed for double posting, tell 'em I sent you.

  9. #9
    Senior Member Jaffasoft's Avatar
    Join Date
    Apr 2001
    Location
    On Travel
    Posts
    1,587
    All you people that expect us to open a Flash 6 file. Why don't you supply the Flash MX program download as well so we can open the fla and look at it.
    But Arrrrr there's another thing you could do. Go to the Flash MX forrum.

  10. #10
    Not PWD ViRGo_RK's Avatar
    Join Date
    May 2001
    Posts
    1,799
    Wow, someone has an attitude to curve.

    This isn't a MX specific problem. And why don't you find the MX download on your own? Stop griping, just live with it. You'll get it eventually.

    By the way, what's bothering you today?

  11. #11
    Junior Member
    Join Date
    May 2002
    Posts
    3

    Smile look this is...

    the number is:
    if (Key.getCode(40)){
    //do anything
    }
    and if you write:
    if (Key.isDown(40)) {
    //do anything
    }
    it is incorrect!
    you could write :

    if (Key.isDown("ENTER")) {
    //do anything
    }
    it would be correct
    my english is ****, isn't it? (I'm an austriam boy)

  12. #12
    Junior Member
    Join Date
    Feb 2001
    Posts
    16
    WTF WTF WTF DONT U UNDERSTAND ME?????? THEY KEYS WOOOOOORK! DOWNLOAD THE MOVIE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
    the problem is the wrong movement what does not fit to the rotation!!!!!!!

  13. #13
    Not PWD ViRGo_RK's Avatar
    Join Date
    May 2001
    Posts
    1,799

    Hey...

    No aditude. It was a mis-understanding.

    For that answer, you need to go to either the physics department, or the action script department. We don't usually answert those kinds of questions.

  14. #14
    Junior Member
    Join Date
    Feb 2001
    Posts
    16
    oh yes, sorry

  15. #15
    Not PWD ViRGo_RK's Avatar
    Join Date
    May 2001
    Posts
    1,799
    It's ok. Sometimes we all lose are cool. Just gotta keep each other in check.

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