on (release) {
_root.gotoAndPlay("styxgood1");
}
on (release) {
exp = + 10;
this. mymc. Styxexp = +10 ;
}
The problem I'm having is that 10 points are being added to my variable inside my movie clip, but when I click on the button again, the points do not increase. When I go to a new frame, the points completely reset. I'm trying to add points to a variable inside my movieclip titled mymc. Does anyone know how to do this? Or know what's wrong with my code?
Hi, thank you for responding. The code sadly didn't work. It did add 10 points to my variable but instead of the number becoming 20 it became 1010.
And the variable also still reset itself......
1> If you are getting 1010 you var is set wrong.
You will have
Code:
var exp = "10";
You want
Code:
var exp = 10;
The "" means it processes the var as a string so you are asking it to add 10 to the string ie 10+10=1010, without the "" it becomes a math problem 10+10=20
2> Your Actions Frame want to be at the highest level and spam the few length ie
My example shows the timeline
Our Root level spans 10 frames in this instance, the actions covers all 10. You want to cover all your frames with the action line.
If you go to a frame without the var on it, when it next goes to a frame with it, will reset.
3> Try to avoid buttons, you want your code at the highest level possible to avoid issues, and make decoding easier.
You can use a movieclip as a button, and the following code on the _root timeline actions.