7 Replies Latest reply on Aug 1, 2010 7:54 AM by Riff88

    two seperate movieclips influence one another

    Riff88 Level 1

      hello,

       

      i have two seperate movie clips on two seperate layers on the front page of my template. (loaded dynamically)

       

      the layers are on top of one another.

       

      the two movie clips work fine one their own on the template, but when i put them both on the template and I press their respective buttons the TOP movieclip's buttons control the BOTTOM movie clips actions. it's crazy.

       

      i've tried to move them around but then it's just the reversed - the bottom buttons control the top movieclip.

       

      any help is appreciated

      thank you!

      Riaan

        • 1. Re: two seperate movieclips influence one another
          Ned Murphy Adobe Community Professional & MVP

          Show one element of coding from each of these movieclips that behaves the way you describe.  Also, show the code you use to load these movieclips.

          • 2. Re: two seperate movieclips influence one another
            carl schooff Level 3

            do your movieclips have unique instance names? i'm guessing they are named with the same name and Flash is only recognizing one of them. just a guess.

            • 3. Re: two seperate movieclips influence one another
              Riff88 Level 1

              Here is the code for the photos to come in. I just changed the X and Y for the other movieclip. (just FYI, Ned - I tried the whole shebang again from start to finish, giving EVERY ITEM a different instance name but I still get the same result)

               

              onClipEvent (load) {

               

                  _root.targetx = 166;

               

                  _root.targety = 0;

               

                  speed = 4;

               

                  _root.onEnterFrame = function() {

               

                      _x += (_root.targetx-_x)/speed;

               

                      _y += (_root.targety-_y)/speed;

               

                  };

               

              }

               

              onClipEvent (enterFrame) {

               

                  if (_y == targety && _x == targetx) {

               

                      delete this.onEnterFrame;

               

                  }

               

              }

               

               

              here are the loadmovie clip code for the two seperate movies:

               

              loadMovie("timelineforreal.swf", "triotimeline");

               

              loadMovie("trioband.swf", "trioband_mc");

               


              I use this code for the buttons:

               

              on (release) {

               

                  _root.targetx =165;

               

                  _root.targety = -415;

               

              }

               

               

              Thanks, Ned.

              • 4. Re: two seperate movieclips influence one another
                Ned Murphy Adobe Community Professional & MVP

                Where are each of those sections of code located?  Do both of the movie files use targetx and targety?

                • 5. Re: two seperate movieclips influence one another
                  Riff88 Level 1

                  Hi Ned,

                   

                  sorry, I should provide more detail next time!

                   

                  I use two seperate movieclips and both use target X and target Y. Movieclip one sits just above Movieclip two. The two are clearly seperated.

                   

                  Movieclip One (a textslider)


                  I use TEN buttons with different X and Y codes. Each has its own code.

                   

                  on (release) {

                   

                       _root.targetx =165;

                   

                      _root.targety = -415;

                   

                  }

                   

                   

                  When you press on each button a long movieclip with different pages (with text on each page) rolls in on various X and Y codes.

                  This is the movielip code:

                   

                  onClipEvent (load) {

                   

                      _root.targetx = 166;

                   

                      _root.targety = 0;

                   

                      speed =  4;

                   

                       _root.onEnterFrame = function() {

                   

                          _x += (_root.targetx-_x)/speed;

                   

                          _y  += (_root.targety-_y)/speed;

                   

                      };

                   

                  }

                   

                  onClipEvent (enterFrame) {

                   

                      if (_y  == targety && _x == targetx) {

                   

                          delete this.onEnterFrame;

                   

                      }

                   

                  }

                   

                   

                   

                  MovieClip Two (photo slider)

                   


                  I use THREE buttons with various X and Y codes. Each button has its own code:

                   

                   

                  on (release) {

                   

                       _root.targetx =165;

                   

                      _root.targety = -415;

                   

                  }


                  When I press on each button a movieclip (with three seperate photos) rolls in on various X and Y codes: (Code is the same as MovieClip One)


                  onClipEvent (load) {

                   

                      _root.targetx = 166;

                   

                      _root.targety = 0;

                   

                      speed =  4;

                   

                       _root.onEnterFrame = function() {

                   

                          _x += (_root.targetx-_x)/speed;

                   

                          _y  += (_root.targety-_y)/speed;

                   

                      };

                   

                  }

                   

                  onClipEvent (enterFrame) {

                   

                      if (_y  == targety && _x == targetx) {

                   

                          delete this.onEnterFrame;

                   

                      }

                   

                  }

                   

                   

                   

                   

                  Then I use the loadmovie actionscript on my template. I create an Emptymovieclip and then put it on stage with the following code:

                   

                   

                  Movieclip One code:

                   

                  loadMovie("timelineforreal.swf",  "triotimeline");

                   

                   

                  Movieclip Two code:

                   

                  loadMovie("trioband.swf", "trioband_mc");

                   



                  Thanks Ned.

                  • 6. Re: two seperate movieclips influence one another
                    Ned Murphy Adobe Community Professional & MVP

                    It's stlll got me a bit confused, but the first thing I recommend trying is to delete what you add... if you add _root.onEnterFrame, then delete _root.onEnterFrame.  If you use the same two variables for every object I have a feeling you have enterframe activities persisting.

                     

                    If I knew better what you were trying to accomplish, I might recommend using actionscript Tweens to manage position animations.  In any case, I recommend getting code off of objects and onto the timeline.  You might find it easier to resolve matters if all your code is in the same place.  Instead of using "on" anything, assign instance names to your objects and assign code to them using those names.

                    1 person found this helpful
                    • 7. Re: two seperate movieclips influence one another
                      Riff88 Level 1

                      Okay, thanks ned,

                       

                       

                      I guess it won't help to have two movieclips with x and y codes on the same page. I will try something else. thanks.