In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: Eye balls

How about using drawEllipse?
Get Adobe Flash player
by H.S 27 May 2015

    Talk

    YoupSolo at 26 May 2015 23:31
    ahah :)
    O_MEG_A at 26 May 2015 23:56
    Thank U S.H :-) U solved it !
    greentec at 31 Aug 2015 18:06
    cute solution

    Tags

    Embed
/**
 * 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();
    }
}