A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: health problem

  1. #1
    Sir solves own questions :-D
    Join Date
    May 2003
    Location
    IL
    Posts
    216

    health problem

    Hi, I was wondering if any of you could tell me how to set my thing up. I want it so that if my health (starts at 100) goes to 0 it will go to frame 2. Do any of you know the script. I tried a few things out but I am no actionscripter. Anything will be thanked kindly

    PS i realize this could go in games, but I thought it was kind of a general flash question.

  2. #2
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    Basically:

    code:

    if (health == 0) {
    _root.gotoAndStop(2)
    }



    You should definetely consider learning how ActionScript works. It's very similar to JavaScript so you can learn one and or the other. It's just a structured way of thinking (IF my health equals zero, THEN do something), same thing as:

    code:

    if (health == 0) {
    //do something (this is a comment and not ActionScript, but you'd put AS here)
    }



    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  3. #3
    Sir solves own questions :-D
    Join Date
    May 2003
    Location
    IL
    Posts
    216
    that script didnt work. It did the same thing as before. I tested it out with a box that takes away 2 health every time you hit it. I hit the box until it went to 0 and it does nothing. I hit it again, and it goes to negative 2
    Any more help?


    PS i get some actionscript, but I just am not good at setting it up myself. I know javascript somewhat.

  4. #4
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    This script wasn't copy/paste because I have no idea how you're referencing "health". You should have a health variable that represents where your health is at (between 0 and 100).


    What are your scripts to make your health go down? If you can show me these, I should be able to help further. Explain a little more about how your movie is built (ie: is your health a "Health Bar" that is a movie clip, or a dynamic text field?) There are a million different ways you could build a "health" bar, which is what's keeping me from being able to give you an exact answer.

    If you can post the FLA, this would help even further.


    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  5. #5
    Sir solves own questions :-D
    Join Date
    May 2003
    Location
    IL
    Posts
    216
    Okay, my variable is "health". The script I used to make health go down was

    Code:
     on (release) {
     _root.score -= 2;
     }
    Is that right?

  6. #6
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    Okay, so your variable name is "score". Here's how to accomplish what you want:

    code:

    on (release) {
    _root.score -= 2;
    if (_root.score <= 0) {
    _root.gotoAndStop(2) //(or use gotoAndPlay if that's what you need.)
    }
    }





    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  7. #7
    Sir solves own questions :-D
    Join Date
    May 2003
    Location
    IL
    Posts
    216
    THANKS A LOT MAN!!

    It was exactly what I needed.

  8. #8
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    Glad I could help!


    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


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