Take a look at the sliding volume control script that was written a few years back.
It uses a single animation frame set to infinite loop, which can be easily moved with a single line of lua script.
You convert a width value (pixels) that is made up of the furthest left pixel coordinate of where the rail should begin to the furthest right pixel where the rail should end. You then calculate the position of the animation on the rail & convert it to a percentage or vice versa to tell the animation where it should be positioned on the rail.
I guess it's pretty complicated to understand when it's just words.
http://pastebin.com/7V9igpPB