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.
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.