Skip to main content
Inspiring
April 16, 2006
Answered

How to make an swf scrubber

  • April 16, 2006
  • 11 replies
  • 947 views
I'd like to put a scrub bar at the top of my movie so users can scrub back and forth through it. I've found a couple pre-built ones at Flashkit.com, but I really would like to learn how to make one myself. Anyone have any suggestions?

Thanks,

Michael
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer rodolfo1216
the complete code is below:


That's it. Everything works perfectly. Thanks again for your time and patience.

Michael

11 replies

April 19, 2006
Would something like this work?

function calculate(){
var amount:Number = (knob_mc._x / track._width) * 100;
var frameNum:Number = Math.round(amount);
}
knob_mc.onPress=function(){
_root.stop();
this.startDrag(false,0, this._y, track._width,this._y);
this.onMouseMove = calculate;
}

knob_mc.onRelease = knob_mc.onReleaseOutside = function(){
this.stopDrag();
_root.gotoAndPlay(frameNum);
}

he types hopefully.........
kglad
Community Expert
Community Expert
April 16, 2006
to make a scrubber (or scrollbars) set-up two (linear) equations in two unknowns. you know the location of your scrubber when it's at each extreme of its range and you know the frames of your timeline (1 and _totalframes) that you want to reference when the scrubber is those extremes. solve for your two unknowns.

you have an equation that gives the frame as function of the scrubber's position and you have an equation that gives the scrubber's position as a function of the timeline's frame.
Inspiring
April 19, 2006
I think I've almost got it, but if anyone wants to give me a little help - it would be much appreciated. I've created the scrubber (called knob_mc) and a track to scrub it on and I've figured out the equation that relates the scrubber to the main timeline (and put this inside a function called "calculate"). Now I'm just not sure what to do to make the timeline move when the user presses on the knob? Here's my code so far:

function calculate(){
var amount:Number = (knob_mc._x / track._width) * 100;
}
knob_mc.onPress=function(){
_root.stop();
this.startDrag(false,0, this._y, track._width,this._y);
this.onMouseMove = calculate;
}

knob_mc.onRelease = knob_mc.onReleaseOutside = function(){
this.stopDrag();
_root.play();
}

Thanks for the help,

Michael
kglad
Community Expert
Community Expert
April 20, 2006
try: