Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-19-2012, 04:01 AM   #1
timwright
Registered User
 
Join Date: Aug 2012
Posts: 1
Default Counting to 8 and starting over

My problem is that I can't seem to reset the countReg var back to 0 once it hits 8. Any ideas? I Would also like to have another button that count backwards to 0 and starts over again at 8.


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
timwright is offline   Reply With Quote
Old 08-19-2012, 05:36 AM   #2
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,400
Default

ActionScript Code:
var countReg:Number; stage.addEventListener(MouseEvent.CLICK, nextReg); function nextReg(event:MouseEvent):void {     if (countReg < 8)     {         countReg++;     }     else     {         countReg = 0;     }     trace(countReg); }
[afz]snickelfitz is offline   Reply With Quote
Old 08-19-2012, 08:34 AM   #3
Impacatus
Senior Member
 
Join Date: Jan 2009
Posts: 163
Default

Code:
(countReg == 0);
There's your problem. Use a double equals == for an if statement, but if you want to assign a value, you need a single equals =. Just change it to:
Code:
countReg = 0;
Impacatus is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:33 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.