Shop Mobile More Submit  Join Login
This is a simple test file that shows how to make eyes that follow the position of your mouse cursor.
This particular flash was done in Flash 8, but I don't see why this shouldn't work with ANY other flash version, since it's only 3 lines of code.
Send me a PM if you are interested in the .fla

And this is how I did it:

0) place "stop()" in the first picture of the root timeline

1) create a movie clip with your eye (if you want that the Iris moves seperatly make it into an own movie clip)

2) use the "onClipEvent(enterFrame)" command in the movie clip to initialise the following commands more or less in real time

3) put "this._x = _xmouse/10" and "this._y = _ymouse/10" in the function.

"this._x" sets the x relative x position for the movie clip the code is in.

The "_xmouse" gets the current x position of the cursor.

So basicly what you do is you set the x position of the moviclip = the x position of the cursor (same for y).

But since it would stick to your cursor like this you divide the current x (or y) position of the cursor through 10 (or any other number) so that it only moves by a certain degree to your cursor.

4) repeat this step for the Iris
(depending on how you made your movieclips you might need to set a fixed x and y offset. Also you need to change the factor the mousepositions are divided through to something smaller to get it like in this test. This way the Irsis will move further to the mouse then the eyes.)

5) you should end up with something like this in every eye (and Iris) you made:

this._x = _xmouse/10
this._y = _ymouse/10}

or (If you get a offset from the original position)

this._x = 100 + _xmouse/10
this._y = 100 + _ymouse/10}

where the 100 would be any x or y offset you need to add (I think that you can avoid this if you place your movieclip in a group or another movieclip)

If you find any mistakes in this, or got any questions about the flash feel free to post your questions in the comments. I'm allways happy to help, as far as I'm possible to.

You want to leave me a comment, but don't got an account
or just want to stay anonymous?
Visit my blog at: [link]
Direct link to this flash: [link]
Add a Comment:
starfennecfox Featured By Owner May 16, 2015  Hobbyist Digital Artist
Woa, this is amazing!
Dagtin Featured By Owner Jun 1, 2015  Hobbyist Traditional Artist
Thank you :)
starfennecfox Featured By Owner Jun 4, 2015  Hobbyist Digital Artist
scotiephantom Featured By Owner Feb 21, 2012
omg i moved my mouse around real fast and made them look in to different dirrections
MoontheOwl Featured By Owner Jun 20, 2011  Student Digital Artist
me: you look tense

eyes: -stare-

me: -pokes eyes- there you go!
Dagtin Featured By Owner Jun 21, 2011  Hobbyist Traditional Artist
MoontheOwl Featured By Owner Jun 21, 2011  Student Digital Artist
PassionHeartDevil Featured By Owner Oct 7, 2010
My cursor is an ice cream! The eyes must be hungry! =p
Dagtin Featured By Owner Oct 8, 2010  Hobbyist Traditional Artist
Dagtin Featured By Owner Mar 12, 2010  Hobbyist Traditional Artist
Wohooo, 1000+ viewers.
JackAssDrawer Featured By Owner Oct 26, 2009
This is fun :XD:
Dagtin Featured By Owner Oct 27, 2009  Hobbyist Traditional Artist
Thank you :D
Dagtin Featured By Owner Apr 26, 2009  Hobbyist Traditional Artist
You could wirte a if command that checks the position of the mouse like

"if((_xmouse >= xyz) || (_xmouse <= xyz) || (_ymouse >= xyz) || (_ymouse <= xyz)) {this._x = _xmouse/10; this._y = _ymouse/10}

where xyz would be defined by the positions of the boarders for the area the effect should be active.

This way you could define a area where the eyes would follow the mouse and where they don't. I'm not quite sure it would work out this way, but this is how I'd approach this problem.

But on the other hand, I wanted this to be as simple as possible to show the people how to use the _x and _xmouse (same for y) command.
horriblePencilist Featured By Owner Apr 26, 2009  Hobbyist General Artist
Cool programming, those eyes got a realistic movement. Except if you move the cursor to far away, maybe you add a maximum distance, like:

if(distance(this._x, this._y, _xmouse, _ymouse) <= 200){


I don't know if there is the statement distance(x1,y1,x2,y2), otherwise it's a pseudocode.
crimsonwonder Featured By Owner Apr 24, 2009
Lol even if this is a "simple test file" I'm having fun xDD
Dagtin Featured By Owner Apr 25, 2009  Hobbyist Traditional Artist
:) thank you
crimsonwonder Featured By Owner Apr 27, 2009
Welcome :]
Add a Comment:


Submitted on
April 24, 2009
Image Size
1.1 KB


33 (who?)