6 Replies Latest reply on Apr 16, 2007 7:30 AM by kglad

    Random Moving Circles

    Matt-R
      I am trying animate the image in the supplied link.

      Basically I want a bunch of circles to move around randomly inside a box. I think I'd also like them to bounce of the edges of the box so that they are moving in all directions.

      The circles will be different sizes so I'm not sure if I need to apply code to each circle size or if there is a scripting way to create randomly sized circles.

      Can anyone help me out, or point me in the direction of a good tutorial. I've been animating in Flash for a while but just begining with action script.

      Thanks!
      sample image
        • 1. Re: Random Moving Circles
          kglad Adobe Community Professional & MVP
          will the circles bounce off each other, too?
          • 2. Re: Random Moving Circles
            Matt-R Level 1
            No the circles don'l need to bounce off each other.
            Hope that makes it easier.
            • 3. Re: Random Moving Circles
              kglad Adobe Community Professional & MVP
              it would make it easier but i already have an experiment that i created where the circles (more like billiard balls) bounce off each other and the table edges.

              i have it on my home computer so i'll check it in a few hours when i get home.
              • 4. Re: Random Moving Circles
                kglad Adobe Community Professional & MVP
                here's the code with balls bouncing off each other. i used four movieclips boxleft, boxright, boxtop, boxbottom to form a rectangular border and there's a ball movieclip with linkage id = ballID

                • 5. Re: Random Moving Circles
                  Matt-R Level 1
                  Thanks for the code!
                  However I tried it and it's not working yet. I think it probably has something to do with the Movie Clips I created.

                  Just to clarify, the things I need to add are:
                  - a ball MC called ballMC
                  - four MCs called boxleft, boxright, boxtop, boxbottom

                  Should I place all these MCs on the stage?
                  What are the names I should give each MC instance?

                  Hope this makes sense.
                  Thanks.
                  • 6. Re: Random Moving Circles
                    kglad Adobe Community Professional & MVP
                    only the box movieclips are onstage to form the border encasing the balls. you can set their _alpha to 0 if you don't want them visible.

                    but you need a ball moviecip with a LINKAGE ID = ballID. remove the ball movieclip from the stage, find it in the library, right click it, click linkage, tick export for actionscript and in the linkage id box type: ballID, then click ok and retest.