2 Replies Latest reply on Aug 18, 2009 10:47 PM by NickDymond

    panning/scrolling movieclip, needs to stop and start on rollover/rollout

    NickDymond

      Hello, I just started a new flash developer job, but I am relatively new to Actionscript itself (seems dumb, I know).

       

      The deal is that we have a movieclip with a jpg in it that we need to scroll left to right based on the mouse's position. This seems fairly straightforward, but there will also be FLV's (flvPlayback) and other various buttons to click on during the panning.

       

      What I need is a way for the MC to stop panning upon rolling over one of the pre-determined buttons.

       

      I inherited the code below and get what it is doing, but I have no idea how to make it stop panning when I need it to, and then "onRollOut" make it start panning again.

       

      bg_mc.onEnterFrame = function() {
         if (hitTest(_root._xmouse, _root._ymouse, true)) {
             mover();
         } else {
             delete panoramic_mc.onEnterFrame;

       

         }
      };

       

      function mover() {
         panoramic_mc.onEnterFrame = function() {
             if (_xmouse<movieMiddle) {
                 if (panoramic_mc._x > movieWidth) {
                     //trace("Move panoramic 1 back");
                     panoramic_mc._x = (panoramic2_mc._x - panoramicWidth);
                 }
                 if (panoramic2_mc._x > movieWidth) {
                     //trace("Move panoramic 2 back");
                     panoramic2_mc._x = (panoramic_mc._x  -panoramicWidth);
                 }
                 inc = Math.abs(_xmouse - movieMiddle)*speed;
                 panoramic_mc._x += inc;
                 if(panoramic_mc._x > panoramic2_mc._x){
                     panoramic2_mc._x = panoramic_mc._x - panoramicWidth;
                 }else{
                     panoramic2_mc._x = panoramic_mc._x + panoramicWidth;
                 }
             } else {
                 if (panoramic_mc._x < (0 - panoramicWidth)) {
                     //trace("Move panoramic 1 ahead");
                     panoramic_mc._x = (panoramic2_mc._x + panoramicWidth);
                 }
                 if (panoramic2_mc._x<(0 - panoramicWidth)) {
                     //trace("Move panoramic 1 ahead");
                     panoramic2_mc._x = (panoramic_mc._x + panoramicWidth);
                 }
                 inc = Math.abs(_xmouse - movieMiddle)*speed;
                 panoramic_mc._x -= inc;
                 if(panoramic_mc._x > panoramic2_mc._x){
                     panoramic2_mc._x = panoramic_mc._x - panoramicWidth;
                 }else{
                     panoramic2_mc._x = panoramic_mc._x + panoramicWidth;
                 }
             }
         }
      }

        • 1. Re: panning/scrolling movieclip, needs to stop and start on rollover/rollout
          kglad Adobe Community Professional & MVP

          when you want the panning to be active call activate():

           


          function activate(){

          bg_mc.onEnterFrame = function() {
             if (hitTest(_root._xmouse, _root._ymouse, true)) {
                 panoramicF()
             }
          };

          }

           

          //when you want it to be inactive call deactivate():

           

          function deactivate(){

          delete bg_mc.onEnterFrame;

          }


            function panoramicF() {
                 if (_xmouse<movieMiddle) {
                     if (panoramic_mc._x > movieWidth) {
                         //trace("Move panoramic 1 back");
                         panoramic_mc._x = (panoramic2_mc._x - panoramicWidth);
                     }
                     if (panoramic2_mc._x > movieWidth) {
                         //trace("Move panoramic 2 back");
                         panoramic2_mc._x = (panoramic_mc._x  -panoramicWidth);
                     }
                     inc = Math.abs(_xmouse - movieMiddle)*speed;
                     panoramic_mc._x += inc;
                     if(panoramic_mc._x > panoramic2_mc._x){
                         panoramic2_mc._x = panoramic_mc._x - panoramicWidth;
                     }else{
                         panoramic2_mc._x = panoramic_mc._x + panoramicWidth;
                     }
                 } else {
                     if (panoramic_mc._x < (0 - panoramicWidth)) {
                         //trace("Move panoramic 1 ahead");
                         panoramic_mc._x = (panoramic2_mc._x + panoramicWidth);
                     }
                     if (panoramic2_mc._x<(0 - panoramicWidth)) {
                         //trace("Move panoramic 1 ahead");
                         panoramic2_mc._x = (panoramic_mc._x + panoramicWidth);
                     }
                     inc = Math.abs(_xmouse - movieMiddle)*speed;
                     panoramic_mc._x -= inc;
                     if(panoramic_mc._x > panoramic2_mc._x){
                         panoramic2_mc._x = panoramic_mc._x - panoramicWidth;
                     }else{
                         panoramic2_mc._x = panoramic_mc._x + panoramicWidth;
                     }
                 }
             }

          • 2. Re: panning/scrolling movieclip, needs to stop and start on rollover/rollout
            NickDymond Level 1

            that works exactly how I wanted it to, thanks so much