Skip navigation
Currently Being Moderated

How to count to 8 and then start over

Aug 18, 2012 8:43 PM

My problem is that I can't seem to reset the countReg var back to 0 once it hits 8. any ideas?

 

 

var countReg:Number = 0;

 

 

function nextReg(event:MouseEvent) : void

{

             if (countReg == 9)

          {

                    (countReg == 0);

           }

          countReg++;

 

          trace (countReg)  // it just keeps counting up. won't start over after 8

 

}

 

 

this.next1_btn.addEventListener (MouseEvent.CLICK, nextReg);

 

 

THANKS MUCH

 
Replies
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 18, 2012 9:10 PM   in reply to TimsterVideo

    function nextReg(event:MouseEvent) : void

    {

    countReg=(countReg+1)%9

     

    }

     
    |
    Mark as:
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 19, 2012 7:21 AM   in reply to TimsterVideo

    use:

    var countReg:int=8

    function prevReg(event:MouseEvent) : void

    {

    countReg=(countReg+8)%9

     

    }

     

    p.s.  please mark helpful/correct responses.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 21, 2012 2:14 AM   in reply to TimsterVideo

    The given solution is nice.And just know where the mistake happen in your code. insed of this "(countReg == 0);" use "countReg = 0". it will work with your own code

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points