Following Eyes

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

Inspired by the Google Eye’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,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.