A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: move movieClip within a range

Threaded View

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    996

    move movieClip within a range

    I have 2 lines that are representing a range that the clip can move within a boundary if you like. My lines are named "left" and "right". What I'm trying to do is move the movieclip based on the mouseX but the mouseX should only move it within the range or boundaries.

    Here is what I have so far.

    Code:
    var cp : Number = left.x + (right.x - left.x) / 2;
    addEventListener(Event.ENTER_FRAME, onLoop);
    var sx : Number = sq.x;
    
    function onLoop( evt : Event ) : void
    {
    	var dx : Number = cp - mouseX;
    	var range = right.x - left.x ;
    	sq.x = dx
    	//trace("dx = "+(dx ));
    }
    I have tried a few different ideas inside the above code but its driving me nuts when it seems like something very easy. The MovieClip should move based on the mouseX but should only move within the left and right clips as boundaries.
    Last edited by ericflash; 05-18-2009 at 07:21 PM.

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