Hi, I’m having trouble figuring this out. I want to have an mc act like an eyeball where it would follow the movement of the mouse but stay in one spot and if the mouse leaves a bufferzoneMC then the eye will bounce back to place. So far I have this.
on the actions layer (thx 2 scotty):
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]var[/COLOR] xp = [COLOR=#000080]0[/COLOR], yp = [COLOR=#000080]0[/COLOR];
[COLOR=#0000FF]MovieClip[/COLOR].[COLOR=#0000FF]prototype[/COLOR].[COLOR=#000080]move[/COLOR] = [COLOR=#000000]function[/COLOR][COLOR=#000000]([/COLOR]centerx, centery, inertia, k[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
x = -[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR]+centerx;
y = -[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR]+centery;
xp = xpinertia+xk;
yp = ypinertia+yk;
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR] += xp;
[COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR] += yp;
[COLOR=#000000]}[/COLOR];
[/LEFT]
[/FONT]
on the eyeMC
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000FF]onClipEvent[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] MAXeyeMovement = [COLOR=#000080]30[/COLOR]
[COLOR=#000000]var[/COLOR] distanceFromEye = [COLOR=#000080]5[/COLOR]
[COLOR=#000000]var[/COLOR] ovality = [COLOR=#000080]1[/COLOR].[COLOR=#000080]5[/COLOR]
[COLOR=#000000]var[/COLOR] origin = [COLOR=#000000]{[/COLOR]x:[COLOR=#000080]116[/COLOR],y:[COLOR=#000080]191[/COLOR][COLOR=#000000]}[/COLOR]
centerx = [COLOR=#000080]116[/COLOR];
centery = [COLOR=#000080]191[/COLOR];
x0 = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR];
y0 = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR];
[COLOR=#0000FF]_root[/COLOR].[COLOR=#0000FF]_xmouse[/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_x[/COLOR];
[COLOR=#0000FF]_root[/COLOR].[COLOR=#0000FF]_ymouse[/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_y[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#0000FF]onClipEvent[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
xdiff = [COLOR=#0000FF]_parent[/COLOR].[COLOR=#0000FF]_xmouse[/COLOR] - origin.[COLOR=#000080]x[/COLOR]
ydiff = [COLOR=#0000FF]_parent[/COLOR].[COLOR=#0000FF]_ymouse[/COLOR] - origin.[COLOR=#000080]y[/COLOR]
radius = [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]min[/COLOR]COLOR=#000000[/COLOR]
angle = [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]atan2[/COLOR]COLOR=#000000[/COLOR]
[COLOR=#0000FF]_x[/COLOR] = [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]cos[/COLOR]COLOR=#000000[/COLOR]radiusovality + origin.[COLOR=#000080]x[/COLOR]
[COLOR=#0000FF]_y[/COLOR] = [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]sin[/COLOR]COLOR=#000000[/COLOR]*radius + origin.[COLOR=#000080]y[/COLOR]
[COLOR=#0000FF]updateAfterEvent[/COLOR]COLOR=#000000[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]
I was advised to try using:
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]Tween[/COLOR];
[COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]easing[/COLOR].*;
[/LEFT]
[/FONT]
but can’t figure out how to get the eyeMC to bounce back to place w/out having to use startDrag();
Any help would be greatly appreciated.