0
votes

I am new to as3. I create a rectangle and convert it to symbol. Then I go into the symbol and create two sliders. Also, I make the symbol draggable.

controlPanel_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragStartF);
controlPanel_mc.addEventListener(MouseEvent.MOUSE_UP, dragEndF);

function dragStartF(e:MouseEvent){
    e.currentTarget.startDrag();
}
function dragEndF(e:MouseEvent){
        e.currentTarget.stopDrag();
}

It works fine, but I can't use the slider. If I drag the slider, the entire movie clip moved. How can I solve this problem? Cheers!

1

1 Answers

0
votes

Without more info on the structure of your FLA-file I assume that controlPanel_mc is the container containing the rectangle[background] and the two sliders.

What it seems like you did in your code was to add event listener to the container, what that means is that "if a click occures anywhere on this object, do the following". Since that clip "owns" the 2 sliders, the sliders will not get any MOUSE_DOWN-events since the parent is always the one handling the event first.

You probably want to convert the background into a symbol and add the eventListeners to that object instead.

bg.addEventListener(MouseEvent.MOUSE_DOWN, onBgClick);
bg.addEventListener(MouseEvent.MOUSE_UP, onBgRelease);

function onBgClick(e:MouseEvent){
    controlPanel_mc.startDrag();
}
function onBgRelease(e:MouseEvent){
    controlPanel_mc.stopDrag();
}

That should solve your issue :)