PDA

View Full Version : help with condition statement


pimuni
04-20-2005, 01:16 AM
hello guys. i am a beginner in actionscript. and i am making my own little game. but I need help with something. i am using a dynamic text for the spaceship hp, and i want the game to perform an action when that dynamic text reaches 0. the Var name of my dynamitc text is "hp". what would go with the if statement to make it work the way i want it to? this is what i have, but it doesnt work for me

onClipEvent (enterFrame) {
if (hp == 0) {
_root.player.Play();
}
}

the spaceship movieclip has its first frame on stop. the rest of the frames r the explosion. i want it to explode when the hp of the ship reaches 0. (it has 200 hp). please help me out

Flash Gordon
04-20-2005, 03:19 AM
onClipEvent (enterFrame) {
if (hp == "0") {
_root.player.Play();
}
}

you were very close.

Barn
04-20-2005, 06:33 AM
And that is because any value displayed in a textField is, by definition, a string (not a number or any other data type).