forked from: Eye balls
How about using drawEllipse?
/**
* Copyright H.S ( http://wonderfl.net/user/H.S )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/uCxX
*/
// forked from O_MEG_A's Eye balls
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class eye_ball extends Sprite{
private var eyeball:RotateToMouse;
public function eye_ball(){
stage.addEventListener(MouseEvent.CLICK, SpareEyeBall);
}
private function SpareEyeBall(event:MouseEvent):void{
eyeball = new RotateToMouse();
addChild(eyeball);
eyeball.x = event.stageX;
eyeball.y = event.stageY;
}
}
}
import flash.display.Sprite;
class EyeBall extends Sprite {
public function EyeBall() {
init();
}
public function init():void {
graphics.lineStyle(1, 0, 1);
graphics.beginFill(0xffffff);
graphics.drawCircle(0,0,20);
graphics.endFill();
graphics.beginFill(0x000000);
graphics.drawCircle(10,0,5);
graphics.endFill();
}
}
import flash.display.Sprite;
import flash.events.Event;
class RotateToMouse extends Sprite {
private var arrow:EyeBall;
private var eyelid:Sprite = new Sprite();
private var size:int = 40;
private var wink:Boolean;
public function RotateToMouse() {
init();
}
private function init():void {
arrow = new EyeBall();
addChild(arrow);
arrow.x = 0;
arrow.y = 0;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
addChild(eyelid);
}
public function onEnterFrame(event:Event):void {
var dx:Number = mouseX - arrow.x;
var dy:Number = mouseY - arrow.y;
var radians:Number = Math.atan2(dy, dx);
arrow.rotation = radians * 180 / Math.PI;
if (Math.floor(Math.random() * 80) == 0 && size == 40) {
wink = true;
}
if (wink && size > 0) {
size -= 5;
}
else if (size < 40) {
wink = false;
size += 5;
}
eyelid.graphics.clear();
eyelid.graphics.lineStyle(1, 0, 1);
eyelid.graphics.beginFill(0xffffff);
eyelid.graphics.drawCircle(0, 0, 20);
eyelid.graphics.drawEllipse( -20, size / -2, 40, size);
eyelid.graphics.endFill();
}
}