The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: Following Eyes

  1. #1

    Following Eyes

    Now this one was a ***** to get working. But I just love that feeling now it does

    Inspired by the Google Eye's avaiable for your personal google page

    Code:
    Stage.scaleMode = "noScale"; //1
    function drawCircle(name, x, y, d, line, colour, fill, par){
    	a = _root.createEmptyMovieClip(name,getNextHighestDepth()); //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.
    Attached Files Attached Files
    Build a man a fire and he is warm for a day.
    Set a man on fire and he is warm for the rest of his life.

  2. #2
    Very nice sam

    -Ben
    If you notice this notice you will notice this notice was inspired by the noticing of another notice.

  3. #3
    Thanks
    Build a man a fire and he is warm for a day.
    Set a man on fire and he is warm for the rest of his life.

  4. #4
    nice, i like how the one eye will follow the mouse even if the mouse is in the middle of the eye !!!

  5. #5
    Does the last } of a for statement not count as a line?

  6. #6
    no
    Build a man a fire and he is warm for a day.
    Set a man on fire and he is warm for the rest of his life.

  7. #7
    icio's Avatar
    3,811
    posts
    looks better in lowercase
    Cool

    But, line 3 should count as 3 lines and line 6 should count as 2 lines, I think.
    "60% of the time it works... every time." -- Paul Rudd as Brian Fantana.

  8. #8
    it's cool, but our eyes don't quite behave the same way. nonetheless, it's cool...

  9. #9
    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;

  10. #10
    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 ...

  11. #11
    nice one! reminds me of some online program which made you make this...nice work man!

  12. #12
    Thanks guys

    Quote Originally Posted by kdd
    it's cool, but our eyes don't quite behave the same way.
    Mine do!

    Yeah, I think 3 is 3 lines, but I'm pretty sure 6 is only 1:

    Code:
    Stage.scaleMode = "noScale"; //1
    function drawCircle(name, x, y, d, line, colour, fill, par){
    	a = _root.createEmptyMovieClip(name,getNextHighestDepth()); //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
    Last edited by Sammo; January 16th, 2006 at 02:31 PM.
    Build a man a fire and he is warm for a day.
    Set a man on fire and he is warm for the rest of his life.

  13. #13
    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.
    Build a man a fire and he is warm for a day.
    Set a man on fire and he is warm for the rest of his life.

  14. #14
    Ha ha, google, lol. Nice work!

    XBOX LIVE GAMERTAG: Icr125riderI


  15. #15
    <spooky voice>Google is watching yoooouuuuu!</spooky voice>
    Build a man a fire and he is warm for a day.
    Set a man on fire and he is warm for the rest of his life.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012