To constrain a slider over a groove for a volume-control interface:
Figure 2: The movie clip instance called groove_mc will limit the motion of the draggable movie clip called slider_mc. Make sure that the registration point of the groove_mc movie clip lies at its bottom edge.
onPress event handler to the slider_mc movie clip.lockCenter parameter tells Flash to drag the object from wherever the mouse pointer clicks it._root.groove_mc._x_root.groove_mc._y - 100_root.groove_mc._x_root.groove._yThese parameter values constrain the left and right sides to the center of the groove_mc movie clip. The top is constrained to 100 pixels above the lower edge of the groove_mc movie clip, and the bottom is constrained to the lower edge of groove_mc (Figure 3).
Figure 3: In the onPress handler for the slider movie clip, the startDrag() method’s second through fifth parameters constrain the slider_mc movie clip from the center point to 100 pixels above the center point of the groove_mc movie clip. Here the method has been split onto five lines, but it works the same written out as one line.
onRelease event handler to the slider movie clip.onRelease event handler, choose Global Functions > Movie Clip Control > stopDrag.
Figure 4: The full script. The slider movie clip can be dragged along the groove movie clip.