Skip navigation
Shockeey
Currently Being Moderated

make a variable change if a score_var == of a multiple of 10?

Sep 23, 2012 1:25 AM

Tags: #cs4 #help #flash #frame #button #as2 #actionscript #movieclip #actionscript_2 #game #movie #clip #2.0 #movie_clip

So I want this *bonus* to move accross the screen if the score is a multiple of 500,

 

bonus_mc.onEnterFrame = function(){

if(score_var ){

this._x +=bonus_speed;

if (this._x > Stage.width)

{

  this._y = random(Stage.height/3);

  this._x = -20;

}

}

}

 
Replies
  • Currently Being Moderated
    Sep 23, 2012 4:38 AM   in reply to Shockeey

    Use the modulus operator to see if a value is a multiple of a number.  If the result is 0 you have a multiple of the value.  Since you specified two different values, your choices are...

     

    if(score_var % 10 == 0){

    or

    if(score_var % 500 == 0){

    And since a score_var of 0 would also produce a 0 result, if you do not want that included, then build it into the conditional as well.

     
    |
    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