-
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);
}
-
Senior Member
I think you need to put this line, fillerMask_mc.x = sliderControl_mc.x-237;, outside of the function, because you always reset the the mask to one position when you drag the slider.
- The right of the People to create Flash movies shall not be infringed. -
-
No dice, tried that and am getting the same issue. It puts it in the correct position initially but it doesn't move when you drag the controller.
-
Senior Member
Where is the code that moves the mask?
- The right of the People to create Flash movies shall not be infringed. -
-
Maybe try something like this...
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);
}
function onReleaseKnob(myEvent:Event):void {
sliderControl_mc.knob_mc.stopDrag();
sliderControl_mc.knob_mc.removeEventListener(Event.ENTER_FRAME,onScrubMovie);
}
function onScrubMovie(myEvent:Event):void {
var playHead:int=Math.round((sliderControl_mc.knob_mc.x/260*23)+1);
fader_mc.gotoAndStop(playHead);
fillerMask_mc.x = sliderControl_mc.x - 237 + sliderControl_mc.knob_mc.x;
}
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|