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

Loop using external variables

Explorer ,
Apr 11, 2014 Apr 11, 2014

I need to make a loop, which keeps a spawned item within the boundaries of the screen. It needs to be like this:

if (square_x + (width/2) > 480)

            {

                square_x = square_x - 5

            }

(square_x is a variable defined before the conditional) but it needs to be a loop, so that it keeps repeating that effect until it satisfies the statement: "square_x < 480"

TOPICS
ActionScript
375
Translate
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
LEGEND ,
Apr 11, 2014 Apr 11, 2014

If you need it to loop, then you might just try using a while loop...

while(square_x >= 480){

   if (square_x + (width/2) > 480){
      square_x = square_x - 5
   }
}

Translate
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
LEGEND ,
Apr 12, 2014 Apr 12, 2014
LATEST

Why do you need a loop? Why not to just position object within boundaries?

Are you talking about initial positioning or keeping object within boundaries while animating it?

Translate
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