This is some great code by peter joel that alows you to drag along a custom path. I need to do the exact same thing in as3. I’ve been trying to do it on my own, but with no luck. I’m halfway decent with as2, i’m an as3 dummy. Can someone help please?
onClipEvent(load){
var drag = false;
var error; // max number of pixels out
var tolerence = 1; // max error
var x; // current x approximation
var y; // current y approximation
var yAbove = 0; // best Approximation above line
var yBelow = 400; // best Approximation below line
}
onClipEvent(enterFrame){
if(drag){
x =_parent._xmouse;
y =_parent._ymouse;
do{
if (_root.belowLine.hitTest(x,y,true)){
yBelow = y;
y = (y+yAbove)/2;
}else{
yAbove = y;
y = (y+yBelow)/2;
}
error = yBelow -yAbove;
} while (error > tolerence);
yAbove = 0;
ybelow = 400;
_x = x;
_y = y;
}
}