Controlling timeline animation playhead with a slider

First off I’m using as2.

I’m planning an animation that needs to be controlled by a slider. For example:
If the the slider is 98% of the way across, the play head would rest at frame 98 on a 100 frame animation. Or, if it’s 50% across (resting in the middle) then the playhead is on frame 50.

I’ve used what I think might be similar math in preloaders before but I’m wondering if there someone can point me in the direction of a tutorial for this type of functionality.

Thanks!

I don’t know of any tutorials, but it shouldn’t be too hard.

Just get the _x of the start of the slider, the _x of the end of the slider, and the current _x of the slider itself (provided it’s a horizontal slider).

From there, you can work out how far the slider is from the start, and get that as a percentage of the total slider distance.

Then, gotoAndStop(sliderPercent); will have your playhead move to a frame between 0 and 100.

Hope this helps. :slight_smile:

Thanks. Looks good. I’ll be messing around with this in a few days. I’ll let you know how it works out for me.

You might find “_totalframes” quite handy.

It gives you the total amount of frames for the Flash file or a movie clip.