3 Replies Latest reply on Sep 28, 2013 12:29 PM by Ned Murphy

    Connect Mouse X value to scrubbing of a video or timeline

    Bjorn Syse

      Hi,

       

      I would like to import a video sequence or object, and scrub it based on the movement of the mouse. So that Mouse X coordinate value gets connected to scrubbing of the video. Mouse moves right, video plays forward, mouse moves left, video scrubs backward. Mouse stops, video stop. Etc..

       

      It could also be a dragging motion with inertia.

       

      Anyone know how I could start accomplishing such a thing?

       

      Best regards

       

      - Björn         

        • 1. Re: Connect Mouse X value to scrubbing of a video or timeline
          Ned Murphy Adobe Community Professional & MVP

          Use a MOUSE_MOVE event listener to detect that the mouse has moved and then have the event handler function read the mouseX position and translate that to whatever frame it represents in the movieclip.  The width of the the stage will represent the length of the movieclip so you take whatever percentage mouseX is relative to the stageWidth and move to the frame of the movieclip that represents that same % ratio relative to the movieclip's total frames.

          1 person found this helpful
          • 2. Re: Connect Mouse X value to scrubbing of a video or timeline
            Bjorn Syse Level 1

            Hi Ned

             

            Thanks for your reply. I've come to some success with your suggestion, thanks a lot! This is what I tried:

             

            1. Imported a sequence of images, 25 frames on a layer.

            2. Put this actionscript on frame 0:

             

            import flash.events.Event;

            import flash.events.MouseEvent;

             

            addEventListener(Event.ENTER_FRAME, init);

             

            function init(e:Event):void

            {

                       removeEventListener(Event.ENTER_FRAME, init);

                       stop();

             

                       // add Event listener for mouse moves.

                 stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove, false, 0, true);

            }

             

            function handleMouseMove(e:MouseEvent):void

            {

                 trace("Mouse moved: " + e.stageX);

                       gotoAndStop(Math.round(e.stageX / 1280 * 25));

             

            }

             

             

            (Frame size is 1280px wide)

             

            I'm gonna trie some more with longer sequences now. Thanks again!

             

            - Björn

            • 3. Re: Connect Mouse X value to scrubbing of a video or timeline
              Ned Murphy Adobe Community Professional & MVP

              You do not need the ENTER_FRAME event listener/handler (init).  Just the code inside init is sufficient with init itself.