Making a movieclip move in relationship to another mc that's being dragged.
So I have a slider that's controlling an animation that inside a mc. That's all working fine. I want the inside of the "track" that the slider is on to fill with color as it's being dragged to the right. I've set it up so there's a mask that reveals that color.
So basically I want my "fillMask_mc" to have the same x position (minus 237 pixels) as "sliderControl_mc" Below is the code I have, and it initially works when you click the sliderControl... but it doesn't move with it when you drag.
Code:
fader_mc.stop();
sliderControl_mc.knob_mc.addEventListener(MouseEvent.MOUSE_DOWN, onDragKnob);
stage.addEventListener(MouseEvent.MOUSE_UP, onReleaseKnob);
sliderControl_mc.knob_mc.buttonMode=true;
function onDragKnob(myEvent:Event):void {
sliderControl_mc.knob_mc.startDrag(false, new Rectangle(0,0,252,0));
sliderControl_mc.knob_mc.addEventListener(Event.ENTER_FRAME, onScrubMovie);
fillerMask_mc.x = sliderControl_mc.x-237;
}
function onReleaseKnob(myEvent:Event):void {
sliderControl_mc.knob_mc.stopDrag();
}
function onScrubMovie(myEvent:Event):void {
var playHead:int=Math.round((sliderControl_mc.knob_mc.x/260*23)+1);
fader_mc.gotoAndStop(playHead);
}