2 Replies Latest reply on Sep 7, 2006 12:20 PM by layerburn

    Scrubbing an animation

    layerburn
      I'm curious if anyone knows how i can scrub through a series of frames so it plays an animation but only when the user clicks and scrubs on it. More precisely i have a series of buttons in a circle, i want to be able to scrub so that the circle rotates and the buttons in the back come around to the front so then the user can access them. The buttons coordinate to parts on an engine and i want the engine to spin around also with the buttons so the user can turn it around to see the backside of it. I didn't know if this would be simple enough to do, i know i've seen it done before, just don't know where i would start. I hope this is clear enough. If anyone could get me started in the right direction i would greatly appreciate it. Thanks in advance!
        • 1. Re: Scrubbing an animation
          Level 7
          layerburn wrote:
          > I'm curious if anyone knows how i can scrub through a series of frames so it
          > plays an animation but only when the user clicks and scrubs on it. More
          > precisely i have a series of buttons in a circle, i want to be able to scrub so
          > that the circle rotates and the buttons in the back come around to the front so
          > then the user can access them. The buttons coordinate to parts on an engine
          > and i want the engine to spin around also with the buttons so the user can turn
          > it around to see the backside of it. I didn't know if this would be simple
          > enough to do, i know i've seen it done before, just don't know where i would
          > start. I hope this is clear enough. If anyone could get me started in the
          > right direction i would greatly appreciate it. Thanks in advance!
          >

          If your animation is in a movieclip and your scrubber is in a separate
          movieclip you could use the onDrag event handler on the scrubber to tell
          the animation movieclip to gotoAndPlay() a specfic frame calculated as a
          percentage of the scrubber location.

          You want to tell the animation to gotoAndPlay a location proportional to
          that of the location of the drag handle inside your scrubber component.
          If the handle is located halfway across the component, then your
          aniamtion should be playing the middle frame.

          // pseudo code, but you get the idea.
          sWidth = scrubber_mc._width; // width of the scrubber component
          sLoc = scrubber_mc.handle_mc._x; // relative location of the handle
          aFrames = 1200; // Number of frames in animation
          thisframe = Math.floor((sLoc/sWidth)*aFrames);
          animation_mc.gotoAndPlay(thisframe);

          James O'Reilly
          www.jamesor.com
          • 2. Scrubbing an animation
            layerburn Level 1
            Ok i think i get what you're saying, but how would i set up a scrub bar and the code should be applied to the scrubber right? I'm fairly new to flash, sorry if this is something really simple. Do you know of a tutorial for something like this? Thanks again.