Hi,
this is my first post on flashkit so sorry if im a bit weak on my description, but anyway.
I am trying to make a simple flash game, which involves a target which moves around, a cursor in the shape of a gun's scope, a healthbar of the target, so it will take multiple shots, and finally a "you win" screen.
I have done the target, the cursor, the healthbar fine. the actionscript works, the healthbar decreases by the given amount etc.
The only problem is, i cant get it to go to the next frame when the healthbar reaches zero.
Im using Actionscript 2.0 and dont really want to change to 3.0 yet.
This is what i have so far...
The frame...
Actionscript Code:
stop(); // The amount of health that the target has. health = 100
This is the script on the healthbar. This works fine as it is.
Actionscript Code:
onClipEvent(enterFrame){ healthwidth = (_root.health*3.2)// for a health bar of 320. the number is what you times 100 by to get the maximum width healthbar._width = healthwidth }
This is the script on the Target. ( a button ).
Actionscript Code:
//This will remove 10 health on release. on(release){ _root.health--; _root.health--; _root.health--; _root.health--; _root.health--; _root.health--; _root.health--; _root.health--; _root.health--; _root.health--; }
(note, is there a way i can get it to remove 10 without repeating that over and over? I tried _root.health - 10, --10 etc. and it wouldnt work.)
Now, heres the problem. When the healthbar empties, nothing happens. how can i get it to proceed to frame 3 when the healthbar becomes empty? (so the health variable, on the frame is 0 or less.)
I have tried...
Actionscript Code:
if(health=0){ gotoAndPlay(3)
But this just set the health value to 0 straight away
};
I have tried >= and <=, More than or equal, puts it to the "you win" screen.
Less than or equal doesnt do anything when the health reaches 0.
I dont know what to do
The fla file is attached for those who want to have a look... (yes its an MX04 file, i made this at school. Thats one reason i dont want to learn AS3 yet.)
hmm... i tried this, but for some reason, it doesnt advance to frame 3.
i have updated the script as you say, but it doesnt move on. check the new attachment...
For help on the othe issue i suggest you attach a copy of the fla in an older version of Flash, like CS3 or 4, since not everybody got CS5 yet (a lot of us are waiting for a more stable CS5)