Flash8 What's wrong with my code?
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: What's wrong with my code?

  1. #1
    Join Date
    Jul 2012

    Exclamation What's wrong with my code?

    Hi, I am having issues with my code:
    on (release) { 
    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?

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011

    You have two on release and some spacings, so maybe something lie so.
    PHP Code:
    on (release) {
    exp += 10
    _root.mymc.Styxexp += 10 ;

  3. #3
    Join Date
    Jul 2012
    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......

  4. #4
    Senior Wabbit
    Join Date
    Jul 2008
    Winchester, Uk
    1> If you are getting 1010 you var is set wrong.
    You will have
    var exp = "10";
    You want
    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

    _root level
    actions - F1 -> F10
    Movieclip - F3 -> F4

    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.
    myButton.onPress = function(){
    	exp += 10;
            mymc.Styxexp += 10 ;
    Out of interest why do you have 2 exp vars in 2 different places?

    This is a image from one of my project to show you what I mean by the actions covering all.

    Trust my code, and not my english.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center