View Full Version : Following Eyes
Sammo
January 15th, 2006, 11:27 AM
Now this one was a ***** to get working. But I just love that feeling now it does :)
Inspired by the Google Eye (http://www.google.com/ig/directory?q=eyes)'s avaiable for your personal google page
Stage.scaleMode = "noScale"; //1
function drawCircle(name, x, y, d, line, colour, fill, par){
a = _root.createEmptyMovieClip(name,getNextHighestDept h()); //2
a._x = x, a._y = y, a.parent = par; //3
a.lineStyle(line,colour,100);//4
a.moveTo(d,0);//5
if (fill) a.beginFill(colour, 100);//6
for(t = 1; t < 360; t++){ //7
a.lineTo((d+d*.25*Math.sin(t*Math.PI/180))*Math.cos(t*Math.PI/180),(d+d*.25*Math.sin(t*Math.PI/180))*Math.sin(Math.PI/180*t)); //8
}
}
function mover () {
c = [_root[this.parent]._x, _root[this.parent]._y+(_root[this.parent]._height/10)]; //9
r = 51; //10
xdist = _xmouse-c[0]; //11
ydist = _ymouse-c[1]; //12
h = Math.sqrt((xdist*xdist)+(ydist*ydist)); //13
newx = xdist*r/h; //14
newy = ydist*r/h; //15
this._x = (h > r) ? newx+_root[this.parent]._x : _xmouse; //16
this._y = (h > r) ? newy+_root[this.parent]._y+15 : _ymouse; //17
}
drawCircle("rightEye", 250, 200, 75, 10, 0xBA0B0B, false, null); //18
drawCircle("leftEye", 440, 200, 75, 10, 0xE4AF00, false, null); //19
drawCircle("rightDot", 0, 0, 20, 1, 0x000000, true, "rightEye"); //20
drawCircle("leftDot", 0, 0, 20, 1, 0x000000, true, "leftEye"); //21
rightDot.onEnterFrame = leftDot.onEnterFrame = mover; //22
22 lines, correct me if I'm wrong.
Ben H
January 15th, 2006, 11:40 AM
Very nice sam ;)
-Ben
Sammo
January 15th, 2006, 12:06 PM
Thanks :D
bombsledder
January 15th, 2006, 01:48 PM
nice, i like how the one eye will follow the mouse even if the mouse is in the middle of the eye !!!
ElectricGrandpa
January 15th, 2006, 07:04 PM
Does the last } of a for statement not count as a line?
Sammo
January 15th, 2006, 07:24 PM
no
icio
January 15th, 2006, 08:51 PM
Cool :)
But, line 3 should count as 3 lines and line 6 should count as 2 lines, I think.
kdd
January 15th, 2006, 09:17 PM
it's cool, but our eyes don't quite behave the same way. :P nonetheless, it's cool...
ElectricGrandpa
January 15th, 2006, 09:29 PM
Yeah icio's right, 3 is 3 lines, but not really sure about 6, as it's basically the same as (fill)? a.beginFill(colour, 100):null;
squan
January 15th, 2006, 09:35 PM
Lol, it's as if my monitor is alive and going "what the fudge is that arrow-thingy doin, ridin all over my face?"
so funny ... :lol:
hybrid101
January 16th, 2006, 06:39 AM
nice one! reminds me of some online program which made you make this...nice work man!
Sammo
January 16th, 2006, 01:34 PM
Thanks guys :D
it's cool, but our eyes don't quite behave the same way.
Mine do! :eye:
Yeah, I think 3 is 3 lines, but I'm pretty sure 6 is only 1:
Stage.scaleMode = "noScale"; //1
function drawCircle(name, x, y, d, line, colour, fill, par){
a = _root.createEmptyMovieClip(name,getNextHighestDept h()); //2
a._x = x, a._y = y, a.parent = par; //3, 4, 5
a.lineStyle(line,colour,100);//6
a.moveTo(d,0);//7
if (fill) a.beginFill(colour, 100);//8
for(t = 1; t < 360; t++){ //9
a.lineTo((d+d*.25*Math.sin(t*Math.PI/180))*Math.cos(t*Math.PI/180),(d+d*.25*Math.sin(t*Math.PI/180))*Math.sin(Math.PI/180*t)); //10
}
}
function mover () {
this._x = ((Math.sqrt(((_xmouse-_root[this.parent]._x)*(_xmouse-_root[this.parent]._x))+((_ymouse-(_root[this.parent]._y+(_root[this.parent]._height/10)))*(_ymouse-(_root[this.parent]._y+(_root[this.parent]._height/10)))))) > 51) ? ((_xmouse-_root[this.parent]._x)*51/(Math.sqrt(((_xmouse-_root[this.parent]._x)*(_xmouse-_root[this.parent]._x))+((_ymouse-(_root[this.parent]._y+(_root[this.parent]._height/10)))*(_ymouse-(_root[this.parent]._y+(_root[this.parent]._height/10)))))))+_root[this.parent]._x : _xmouse; //11
this._y = ((Math.sqrt(((_xmouse-_root[this.parent]._x)*(_xmouse-_root[this.parent]._x))+((_ymouse-(_root[this.parent]._y+(_root[this.parent]._height/10)))*(_ymouse-(_root[this.parent]._y+(_root[this.parent]._height/10)))))) > 51) ? ((_ymouse-(_root[this.parent]._y+(_root[this.parent]._height/10)))*51/(Math.sqrt(((_xmouse-_root[this.parent]._x)*(_xmouse-_root[this.parent]._x))+((_ymouse-(_root[this.parent]._y+(_root[this.parent]._height/10)))*(_ymouse-(_root[this.parent]._y+(_root[this.parent]._height/10)))))))+_root[this.parent]._y+15 : _ymouse; //12
}
drawCircle("rightEye", 250, 200, 75, 10, 0xBA0B0B, false, null); //13
drawCircle("leftEye", 440, 200, 75, 10, 0xE4AF00, false, null); //14
drawCircle("rightDot", 0, 0, 20, 1, 0x000000, true, "rightEye"); //15
drawCircle("leftDot", 0, 0, 20, 1, 0x000000, true, "leftEye"); //16
rightDot.onEnterFrame = leftDot.onEnterFrame = mover; //17
Got rid of a few needless lines in the mover function (var's that didn't need to be there). It's now 17 lines, all correct now I beleive. :)
Lines 11 and 12 are really really nasty now, but they're legal. They're working out pythag's theory, then checking if it's bigger than the radius and if so they need answer to pythag again so they work it out again and proportionally shrink the x and y coords of the mouse until they fit inside the eye circle and then placing the dot's there instead of at the mouse when the mouse is out the circle.
H'mm, I'll have to throw something else in there now i have another 8 lines :)
Sammo
January 16th, 2006, 02:16 PM
PS i'm thinking about porting this to JS and making a konfabulator..(sorry, yahoo widget :roll: ) out of it, I think it'll be really cool to have your desktop follow your mouse, I'll keep you posted on it.
cr125rider
January 27th, 2006, 02:29 AM
Ha ha, google, lol. Nice work!
Sammo
January 27th, 2006, 03:09 PM
<spooky voice>Google is watching yoooouuuuu!</spooky voice> :)
Seb Hughes
January 27th, 2006, 03:25 PM
Groovy.
Sammo
January 27th, 2006, 07:19 PM
Groovy.
:lol::lol: coming from you i guess that means "crap" as "Wow thats really good, im a judge and this is a good contenter." Is your "good" ;)
roll4life
December 11th, 2006, 05:27 AM
aahahah, great Sammo!
I'was searching for something like that for long, long time...heeh
because I'm too dump to do it alone...
til then,
roll4life
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.