PDA

View Full Version : Works in Flash5 but not 8


jdurand
03-09-2008, 09:35 PM
Can any of you gurus see anything in this code which would cause problems in Flash8. It works in Flash5.
It is a script to make eyes follow the mouse.
It is the only script that I found that I can modify to make the eyes follow a MC on a guide path. All the others seem to have problems on the math side of things when you get them to follow an object instead of the mouse.

Jim Durand

onClipEvent (mouseMove) {
tX = _parent._xmouse;
// tX/tY are 'target' X/Y.
tY = _parent._ymouse;

// and now the hurting begins
// get XY of center of constraint zone
cX = _parent.constraintzone._x;
// cX/cY are 'constrained' X/Y,
cY = _parent.constraintzone._y;
// found somewhere inside the constraint zone.
accuracy = 1;
// smaller = more accurate.
do {
dX = (tX-cX)/2;
// dX/dY are deltas to the midpoint between
dY = (tY-cY)/2;
// target XY and constrained XY.
if (_parent.constraintzone.hittest((tX-dX), (tY-dY), true)) {
cX += dX;
// midpoint is in; step out towards mouse.
cY += dY;
} else {
tX -= dX;
// midpoint is out; step in towards center.
tY -= dY;
}
// loop end.
// (dD > .5) is more accurate, (dX > 10) is less.
} while ((Math.abs(dX)>accuracy) || (Math.abs(dY)>accuracy));
_x = tX;
// we're done, set the final position.
_y = tY;
}

jdurand
03-10-2008, 04:34 AM
It was so obvious it makes me sick. I can't believe how much time I spent on this.
The problem was that Flash 5 wasn't case sensitive.
All I had to do was change "hittest" to"hitTest" and everything worked fine.

Jimbo

atomic
03-10-2008, 04:55 AM
Ah! Good old Flash 5 days!