At 12/26/12 03:59 PM, Uniporn wrote:
Hey I want to constantly decrease health if nothing is done and my frame code is:
if(body._currentframe == "idle"){
_root.pl-=random(10);
}
So basically the idea is if animation idle for object "body" is played -> decrease health but nothing happens. Why?
Thanks
1) Learn to debug.
Your most powerful debugging tool is the "trace" function.
if(something){
trace("Something is happening!");
}
This would output "Something is happening" when that if statement is working.
You can also output variables.
trace(body._x);
Would output the body's x position.
So in your case, if you added a trace inside the statement, you'd see it doesn't happen. Then you would trace the body._currentFrame, and you'd see that the output is a number, not a string.
MovieClip._currentFrame returns the number of the current frame. I believe there is Movieclip._currentLabel (not sure if that's the exact syntax), but that would be the property that will tell you the frame label.
Hope this helped.