dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Constrain mask drag

  1. #1
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377

    Constrain mask drag

    Hi,
    I am dragging a mask MC with the below code however I would like to contrain the x values to between 200 and 600 but can't get me head around it. Any ideas? Thanks.

    code:

    onClipEvent (enterFrame) {
    _x += (_parent._xmouse-_x)*.15;
    }


  2. #2
    Between Flash & Flashkit timothye's Avatar
    Join Date
    Dec 2003
    Location
    Sweden
    Posts
    1,666
    hey try this on your mc ..with the instance name dragger_mc..
    Code:
    //dragger_mc instancename 
    dragger_mc.onPress = function() {
    	//self explanitory
    	startDrag(this, true, 200, 50, 600, 50);
    	//trace to get y position ,change it to x to get that positio
    	trace("_root.dragger_mc._y"+_root.dragger_mc._y);
    };
    dragger_mc.onRelease = function() {
    	stopDrag();
    };
    I want to learn .
    wannabe flasher [ Actionscript 2.0 ]

  3. #3
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377
    The code posted by timothye doesn't work for me. (thanks for the help though tim)

    I like the code I have because the mask MC just follows the mouse w/a smooth ease to it and there is no clicking needed by the user. Any other ideas on contraining this mask drag? Thanks.

  4. #4
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    onClipEvent (enterFrame) {
    if(_x<600&&_x>200){
    _x += (_parent._xmouse-_x)*.15;
    }
    }

  5. #5
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377
    The code posted by rdoyle720 is almost exactly what I need. The problem is when the MC reaches the boundries it just 'dies' and can't be dragged anywhere else. Any ideas? Thanks again.

  6. #6
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Are you actually dragging the clip, or just making it move toward the mouse?

  7. #7
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377
    I guess technically you could say I am just making the MC follow the mouse (w/easing).

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