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...
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.
Well, you may or may not want to stopDrag(). Your loop could also "project" back to keep the item moving along the border.
Don't see what you're looking for? Try a search.
|