• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to count to 8 and then start over

Guest
Aug 18, 2012 Aug 18, 2012

Copy link to clipboard

Copied

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

TOPICS
ActionScript

Views

737

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 18, 2012 Aug 18, 2012

function nextReg(event:MouseEvent) : void

{

countReg=(countReg+1)%9

}

Votes

Translate

Translate
Community Expert ,
Aug 18, 2012 Aug 18, 2012

Copy link to clipboard

Copied

function nextReg(event:MouseEvent) : void

{

countReg=(countReg+1)%9

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 18, 2012 Aug 18, 2012

Copy link to clipboard

Copied

Wow. That's awesome. How about another button that counts backwards untill it gets to 0 and then starts over at 8.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2012 Aug 19, 2012

Copy link to clipboard

Copied

use:

var countReg:int=8

function prevReg(event:MouseEvent) : void

{

countReg=(countReg+8)%9

}

p.s.  please mark helpful/correct responses.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 21, 2012 Aug 21, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 21, 2012 Aug 21, 2012

Copy link to clipboard

Copied

LATEST

Thanks!

cid:image001.jpg@01CD7F7A.AA9D8500

Tim Wright  |  Instructional Designer

[... personal contact info removed ...]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines