A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    24

    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);    
    }

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,425
    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. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Junior Member
    Join Date
    Nov 2008
    Posts
    24
    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.

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,425
    Where is the code that moves the mask?
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    :
    Join Date
    Dec 2002
    Posts
    3,494
    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;
    }

  6. #6
    Junior Member
    Join Date
    Nov 2008
    Posts
    24
    That did it! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts




Click Here to Expand Forum to Full Width


HTML5 Development Center