11 Replies Latest reply on Dec 22, 2006 9:55 AM by kglad

    random location for a random movie clip

    badhams
      I have various movie clips which I need to appear in one of four locations randomly. I need the movie clip to also be random. I also need more than one movie clip on stage at the same time. I believe the following needs to be used:

      Math.random
      duplicateMovieClip

      I also believ that the method needs to be generic. Apart from that I am stuck.

      Any help/ideas are appreciated.

      Hope my question makes sense?
        • 1. Re: random location for a random movie clip
          kglad Adobe Community Professional & MVP
          what are the names or ids of the movieclips that you want to position?
          how many (or what range of numbers) do you want on-stage?
          are the four locations to be randomly selected? if so, are there any constraints (like a movieclip placed at that location must be entirely visible or there should be no movieclip overlap)?
          and what do you mean by generic?
          • 2. Re: random location for a random movie clip
            badhams Level 1
            I have sent you a private message detailng what I am trying to achieve
            • 3. Re: random location for a random movie clip
              kglad Adobe Community Professional & MVP
              why private? it's not unusual for others to follow a thread that is of interest to them. that way more than 1 person can learn from each thread.
              • 4. Re: random location for a random movie clip
                badhams Level 1
                good point. to be honest thinking about it I dont really know why

                **************
                I have four movie clips, which the user controls called
                user1
                user2
                user3
                user4.

                In addition I have 6 additional movie clips which I need to appear and move (randomly) in one of four locations (based on a standard stage size):

                locations 1 (start position)
                x co-ordiantes 138.3
                y co-ordiantes 62.8

                locations 2 (start position)
                x co-ordiantes 549.3
                y co-ordiantes 53.8

                locations 3 (start position)
                x co-ordiantes 137.3
                y co-ordiantes 156.8

                locations 4 (start position)
                x co-ordiantes 543.3
                y co-ordiantes 147.8

                locations 1 (finish position)
                x co-ordiantes 291.3
                y co-ordiantes 162.8

                locations 2 (finish position)
                x co-ordiantes 397.3
                y co-ordiantes 162.8

                locations 3 (finish position)
                x co-ordiantes 280.3
                y co-ordiantes 257.8

                locations 4 (finish position)
                x co-ordiantes 400.3
                y co-ordiantes 258.9

                The maximum number of movie clips moving between the two positions at once should be 6. Ideally more than one from one location

                I would also like the speed at which they move to be different.

                The idea is that if a colission occurs between any one of the moving movie clips and the avatar(user 1-4) then points are added.


                Hope this helps.

                Thanks
                ******************
                • 5. Re: random location for a random movie clip
                  kglad Adobe Community Professional & MVP
                  will there be (up to) six moving between each pair of start/finish positions?

                  what determines when a movieclip is to appear at a start position?

                  what path are the movieclips to take when they move from a start to finish position?

                  do the movieclips move at a constant speed?

                  what happens when a movieclip reaches the finish position?
                  • 6. Re: random location for a random movie clip
                    badhams Level 1
                    will there be (up to) six moving between each pair of start/finish positions?

                    yes

                    what determines when a movieclip is to appear at a start position?

                    Nothing really determines when. They just appear randomly in either of the four locations.

                    what path are the movieclips to take when they move from a start to finish position?

                    the start and and finish co-ordiantes are diagonally apart from each other (start 1 is diagonally above finish 1 etc) . If a movie clip was starts at start position one I need it to finish a start position 2

                    do the movieclips move at a constant speed?
                    yea the speed at which any one instance of a movie clip movies should be constant from its start point to its finsh point. Just the speed of one movie clip instance when compared to another should ideally be different (random)

                    what happens when a movieclip reaches the finish position?

                    I currently coding the hit test methods so that if any four of the avatars hit one of the movieclips then the players score is altered or the number of lives they have is reduced.

                    Hope this helps
                    I really appreciated the help.
                    thanks
                    • 7. Re: random location for a random movie clip
                      kglad Adobe Community Professional & MVP
                      so movieclips appear at a start position at random times.

                      within what time range do you want one to randomly appear? should it appear at one of the start positions chosen randomly and regardless if there's already one on-stage that's started from the same spot?

                      the movieclips move in a straightline?

                      what happens to the movieclip is there is a collision with an avatar? what happens to the movieclip when there is no collision? does it just stop at the finish position and stay there?
                      • 8. Re: random location for a random movie clip
                        badhams Level 1
                        so movieclips appear at a start position at random times.

                        yes

                        within what time range do you want one to randomly appear? should it appear at one of the start positions chosen randomly and regardless if there's already one on-stage that's started from the same spot?

                        ideally the time range should be random. That the main idea about what I am trying to achieve. Yes it should not matter if a nother movie clip has already started from the same spot.

                        the movieclips move in a straightline?

                        yes a straight line between start 1 and finish 1 (for example).

                        what happens to the movieclip is there is a collision with an avatar? what happens to the movieclip when there is no collision? does it just stop at the finish position and stay there?

                        if there is a colission with an avatar then depending on the movieclip that hits then either of the following could happen

                        1. points added to the users score ( the number of points one movie clips adds will b edifferent to the numbe rof movie clips that another movie clip adds

                        2. lives added
                        3. lives removed

                        If there is no colission with the avatar then they disappear and reset to a position outside of the stage,.ready to be reposition any one of the start positions.

                        Thanks
                        • 9. Re: random location for a random movie clip
                          kglad Adobe Community Professional & MVP
                          this will get you started (or finished):

                          • 10. Re: random location for a random movie clip
                            badhams Level 1
                            I have attached the code the the frame (in the main scene) where all the movie clips are.

                            I have also renamed the linkages for the movie clips but it dont work?

                            I have no idea as to why not

                            • 11. Re: random location for a random movie clip
                              kglad Adobe Community Professional & MVP
                              the movieclips are in the library, not on-stage. to assign a linkage id, right click on one of the movieclips in your library, click linkage, tick export for actionscript and type the correct linkage id in the appropriate box.