Deviant Login Shop  Join deviantART for FREE Take the Tour
×



Details

Submitted on
April 24, 2009
Image Size
1.1 KB
Resolution
550×400
Link
Thumb
Embed

Stats

Views
4,799 (4 today)
Favourites
33 (who?)
Comments
14
Downloads
1,129
×
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:

onClipEvent(enterFrame){
this._x = _xmouse/10
this._y = _ymouse/10}

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

onClipEvent(enterFrame){
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.



NOTE:
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:
 
:iconscotiephantom:
scotiephantom Featured By Owner Feb 21, 2012
omg i moved my mouse around real fast and made them look in to different dirrections
Reply
:iconmoontheowl:
MoontheOwl Featured By Owner Jun 20, 2011  Student Digital Artist
me: you look tense

eyes: -stare-

me: -pokes eyes- there you go!
Reply
:icondagtin:
Dagtin Featured By Owner Jun 21, 2011  Hobbyist Traditional Artist
hehe
Reply
:iconmoontheowl:
MoontheOwl Featured By Owner Jun 21, 2011  Student Digital Artist
:iconderpplz:
Reply
:iconpassionheartdevil:
PassionHeartDevil Featured By Owner Oct 7, 2010
My cursor is an ice cream! The eyes must be hungry! =p
Reply
:icondagtin:
Dagtin Featured By Owner Oct 8, 2010  Hobbyist Traditional Artist
lol
Reply
:icondagtin:
Dagtin Featured By Owner Mar 12, 2010  Hobbyist Traditional Artist
Wohooo, 1000+ viewers.
Reply
:iconjackassdrawer:
JackAssDrawer Featured By Owner Oct 26, 2009
This is fun :XD:
Reply
:icondagtin:
Dagtin Featured By Owner Oct 27, 2009  Hobbyist Traditional Artist
Thank you :D
Reply
:icondagtin:
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.
Reply
Add a Comment: