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: ギョロギョロ

wonderflひさしぶり!
Get Adobe Flash player
by fukt 19 Feb 2013
/**
 * Copyright fukt ( http://wonderfl.net/user/fukt )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pM3H
 */

// forked from osamX's ギョロギョロ
/**
 * wonderflひさしぶり!
 */
package 
{
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class Gyoro extends Sprite 
    {
        private var eyeArr:Array = [];
        
        public function Gyoro():void 
        {
            var i:int = 0;
            for (var y:Number = -27.5; y < 465; y += 40) {
                for (var x:Number = -27.5; x < 465; x += 40) {
                    var eye:Eye = new Eye(20,10);
                    eye.x = x;
                    eye.y = y;
                    eyeArr[i] = eye;
                    addChild(eyeArr[i++]);
                }
            }
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        private function onEnterFrame(e:Event):void {
            for (var i:int = 0; eyeArr[i] != null; i++) {
                eyeArr[i].move();
            }
        }
        
    }
    
}

import flash.display.Sprite;

class Eye extends Sprite {
    public var iris:Sprite;
    private var bSize:Number;
    private var iSize:Number;
    
    public function Eye(bsz:Number = 100, isz:Number = 50, bCol:int = 0x0, iCol:int = 0xFFFFFF):void {
        bSize = bsz;
        iSize = isz;
        
        //draw base
        this.graphics.beginFill(bCol);
        this.graphics.drawCircle(0, 0, bSize);
        this.graphics.endFill();
        
        //draw iris
        iris = new Sprite();
        iris.graphics.beginFill(iCol);
        iris.graphics.drawCircle(0, 0, iSize);
        this.addChild(iris);
    }
    
    public function move():void {
        var x:Number = this.mouseX;
        var y:Number = this.mouseY;
        var r:Number = Math.sqrt(x * x + y * y);
        
        if ( r < bSize-iSize ) { //cursor in the eye
            iris.x = x;
            iris.y = y;
        }else {
            iris.x = (bSize-iSize) * Math.cos(Math.atan(y / x));
            iris.y = (bSize-iSize) * Math.sin(Math.atan(y / x));
            if (x < 0){ iris.x *= -1; iris.y *= -1; }
        }
    }
}