6 Replies Latest reply on Jun 15, 2012 8:18 AM by Ned Murphy

    Making movie clip disappear with button

    Cather

      Hi All,

      Thank you very much for looking at my post and I hope you can answer my question

       

      Basically I have an interactive 3D project that when the viewer clicks on the window and drags either right or left, then it appears like they are rotating a 3D model I rendered out in Maya. Really all they are doing is moving the mouse on the x axis which causes the movie clip to play backwards or forwards.

      The code that I got from this site works like a dream! I even have made it so that as they click a next button that it goes to another almost identical movie clip and it will start from the same frame as the previous movie clip left off from. I'm rather proud of myself at the moment

      However - on the second almost identical movie clip (mc_2) it has some labels on the images. And what I really want to do is, on mouse press for the labels to disappear and when the viewer has finished scrubing through the time line with mouse drag and releases the mouse, that the labels reappear!

      Very much like this here : http://bmc.erin.utoronto.ca/~enid/interactivethyroidectomy/

       

      So I worked out this code which works perfectly in a little test project I did. I put this code on a button called it my_btn and then made a label and changed it into a movie clip called my_mc, and it all worked perfect

       

      on (press) {

      _root.my_mc._visible = false;

      }

      on (release) {

      _root.my_mc._visible = true;

      }

       

      But what I really need to do is for my previous movieclip, mc_2, to use the code above. However, if I add it anywhere amoungst my previous actionscript coding in the layer mc_2, then the viewer can no longer scrub through the time line anymore. Clearly this code above is affected my previous code. which is:

       

      stop();

      mc_2.stop();

      var startX:Number;

      var startFrame:Number;

      var changeDistance:Number;

      var travelDistance:Number;

      mc_2.onPress = pressHandler;

      mc_2.onRelease = releaseHandler;

      mc_2.onReleaseOutside = releaseHandler;

      function pressHandler():Void {

      startX = mc_2._xmouse;

      startFrame = mc_2._currentframe;

      this.onMouseMove = moveHandler;

      }

      function releaseHandler():Void {

      this.onMouseMove = null;

      }

      function moveHandler():Void {

      changeDistance = mc_2._xmouse - startX;

      travelDistance = startFrame + changeDistance;

      if (travelDistance > mc_2._totalframes) {

      mc_2.gotoAndStop(travelDistance % mc_2._totalframes);

      } else if (travelDistance < 0) {

      mc_2.gotoAndStop(mc_2._totalframes + (travelDistance % mc_2._totalframes));

      } else {

      mc_2.gotoAndStop(travelDistance);

      }

       

      }

       

      Just so I'm ultra clear about the various layers etc

      On scene 1 i have four layers

      Actions, buttons, movie clips and background

      In frame two it has the actionscript listed above, and then mc_2

      Inside mc_2 are 100 frames of a 360 degree view images of a shoulder rendered from Maya

      in the layer above the images I have the labels - one of which ive converted into a movieclip called my_mc for the purpose of this post.

       

      So what i need to do is to add somewhere into the actionscript for the mc_2 that together with all the mouse presses, and releases for it to also make a specific mc (my_mc) invisible when the mouse is pressed, and to re appear when mouse is released.

      I hope that makes sence.

       

      Thank you very much for your help in advance.

      Cat

        • 1. Re: Making movie clip disappear with button
          Ned Murphy Adobe Community Professional & MVP

          As best I can tell from your deascription, you need to put the two lines of code into your pressHandler and releaseHandler functions.

           

          function pressHandler():Void {

             startX = mc_2._xmouse;

             startFrame = mc_2._currentframe;

             this.onMouseMove = moveHandler;

             my_mc._visible = false;

          }

           

          function releaseHandler():Void {

             this.onMouseMove = null;

             my_mc._visible = true;

          }

          • 2. Re: Making movie clip disappear with button
            Cather Level 1

            Wow that was great - thank you so much for your time.

            It worked perfectly if my_mc is on Scene 1 - I was wondering if there was a way it would also work it was on top of the images inside mc_2?

            I'll try and explain myself - its very hard to discribe -

            Basically because the mc_2 has 100 images that show a rotating shoulder - then the labels in the layer above also move and shift as the mc plays because muscles go in and out of view depending on what angle you are looking at the shoulder. So my_mc also needs to move a little bit as its muscle moves around the scene.

            So my_mc really should be on the layer above the images.

            But this means that back on scene 1 the code isn't affecting my_mc which is inside mc_2

            I added to your code roots but that didnt work

             

            function pressHandler():Void {

            startX = mc_2._xmouse;

            startFrame = mc_2._currentframe;

            this.onMouseMove = moveHandler;

            _root.btn_Deltoid._visible = false;

            }

            function releaseHandler():Void {

            this.onMouseMove = null;

            _root.btn_Deltoid._visible = true;

            }

             

            Maybe I'm doing something wrong - I'm only a beginner at action script.

            Thanks again so much for your time and being soooo very quick at getting back to me - I very much appreciate it. If you would like me to send you the flash file if i'm making no sence at all then I could do that too

            Thanks again

            Cat

            • 3. Re: Making movie clip disappear with button
              Cather Level 1

              Sorry - this is how I changed the code - ignore that one above - the btn/mc names are not as i have described. I changed them for the benefit of this post

               

              function pressHandler():Void {

              startX = mc_2._xmouse;

              startFrame = mc_2._currentframe;

              this.onMouseMove = moveHandler;

              _root.my_mc._visible = false;

              }

              function releaseHandler():Void {

              this.onMouseMove = null;

              _root.my_mc._visible = true;

              }

              • 4. Re: Making movie clip disappear with button
                Ned Murphy Adobe Community Professional & MVP

                If you want to target something inside mc_2, then just target mc_2 as part of the path...

                 

                mc_2.my_mc._visible = false;

                • 5. Re: Making movie clip disappear with button
                  Cather Level 1

                  Oh my gosh you are such a saviour!!!!

                  Thank you so much. I owe you one cold and very large beer!

                  Thanks so much for your time!

                  • 6. Re: Making movie clip disappear with button
                    Ned Murphy Adobe Community Professional & MVP

                    You're welcome