-
Sir solves own questions :-D
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.
-
Lifesaver
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)
}
-
Sir solves own questions :-D
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.
-
Lifesaver
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.
-
Sir solves own questions :-D
Okay, my variable is "health". The script I used to make health go down was
Code:
on (release) {
_root.score -= 2;
}
Is that right?
-
Lifesaver
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.)
}
}
-
Sir solves own questions :-D
THANKS A LOT MAN!!
It was exactly what I needed.
-
Lifesaver
Glad I could help!
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
|