I am using percentage and have no clue as to why my code won't work.
I have searched google, many many flash communities with documentation, and tuts on SP. And nothing helps. It is such a simple problem, but yet it is very stuborn.
I have a dynamic text field with a var name of health.
here is the code I am using to decrease it.
function doDamage(damage:Number) {
if (_root.health != Number(0)) {
_root.health -= damage; // Returns NaN
}else{
die();
}
refreshIndicator();
}
All it does is return "NaN".
When I do the following though (outside of this function):
_root.health = 10; // Works
_root.health = Number(10); // Works
_root.health -= 10; // Doesn't
_root.health = _root.health - 10; // Doesn't
_root.health = _root.health - Number(10);// Doesn't
_root.health = Number(_root.health - 10);// Doesn't
Can someone help me figure out what operations to use to decrease the number in the dynamic textbox?