A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Making a movieclip move in relationship to another mc that's being dragged.

  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
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    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. -

  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
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Where is the code that moves the mask?
    - The right of the People to create Flash movies shall not be infringed. -

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