Groups | Blog | Home
all groups > flash actionscript > march 2006 >

flash actionscript : Using startDrag to move an object



DuhChamp
3/15/2006 10:00:36 PM
Using start Drag


--------------------------------------------------------------------------------

I need to create a movable button that follows the top, left and right border
of the screen, and a diagonal line that comes up from the bottom and intersects
in the middle of the right border. I am trying to use the startDrag() function,
but it only updates the bottom value once i release the mouse button. Here is
what I have so far.

on(press){
yVal = (-1 * (this._x)) + 650;
curX = this. _x;

if(curX == this._x)
{
startDrag(this,false,90,90,910,yVal);
}
else {
stopDrag();
curX = this._x;
yVal = (-.5* ( this._x)) + 650;
}

What I want this to do is for every change in x value, update the new bottom
value with the in respect to the x value. A line is represented by y = mx + b,
where m is the slope, x is the x value, and b is the y intersect. y then gets a
value from that expression.

This is what I want it to do, but it is not working. Anyone know why?

Oh, and my screen resolution is 1000 * 700, which explains the large y
intersect.


It doesn't seem to be entering my else statement, I'm not exactly sure why...
kglad
3/15/2006 10:26:53 PM
if you're trying to restrict dragging to a non-rectangular region, you need to
initiate a loop upon startDrag() that continually checks the objects position
and executes a stopDrag() when the object is moved beyone the boundary of your
non-rectangular region.
kglad
3/16/2006 12:00:00 AM
Rothrock
3/16/2006 1:42:32 AM
Well, you may or may not want to stopDrag(). Your loop could also "project" back to keep the item moving along the border.
DuhChamp
3/16/2006 1:53:40 AM
DuhChamp
3/16/2006 2:47:31 AM
AddThis Social Bookmark Button