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

目玉

Get Adobe Flash player
by awef 03 Mar 2009
    Embed
/**
 * Copyright awef ( http://wonderfl.net/user/awef )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/kEXe
 */

package
{
    import flash.display.*;
    import flash.events.*;
    
    public class main extends Sprite
    {
        private var obj:Array = new Array();
        
        private function add(o:DisplayObject):void
        {
            obj.push(o);
            stage.addChild(o);
        }
        
        function main()
        {
            add(new eyeball(stage.stageWidth / 3 * 1, stage.stageHeight / 2, 40));
            add(new eyeball(stage.stageWidth / 3 * 2, stage.stageHeight / 2, 40));
            /* メモ用
            for(var ix:uint = 0; ix < 10; ix++)
            {
                for(var iy:uint = 0; iy < 10; iy++)
                {
                    add(new eyeball(450 / 10 * ix + 22.5, 450 / 10 * iy + 22.5, Math.round(Math.random() * 15 + 5)));
                }
            }
            */
            stage.addEventListener(Event.ENTER_FRAME, frame);
        }
        
        private function frame(e:Event):void
        {
            for(var i:String in obj)
            {
                obj[i].run();
            }
        }
    }
}

import flash.display.*;
import flash.geom.Point;

class eyeball extends Shape
{
    private var r:uint;
    private var r2:uint;
    
    function eyeball(arg_x:uint, arg_y:uint, arg_r:uint)
    {
        x = arg_x;
        y = arg_y;
        r = arg_r;
        r2 = arg_r / 3;
    }
    
    public function run():void
    {
        graphics.clear();
        
        graphics.lineStyle(5, 0);
        graphics.drawCircle(0, 0, r);
        
        graphics.beginFill(0, 1);
        if(r - r2 > Point.distance(new Point(x, y), new Point(stage.mouseX, stage.mouseY)))
        {
            graphics.drawCircle(stage.mouseX - x, stage.mouseY - y, r2);
        }
        else
        {
            var p:Point = Point.polar(r - r2, -Math.atan2(x - stage.mouseX, y - stage.mouseY) - 90 * Math.PI / 180)
            graphics.drawCircle(p.x, p.y, r2);
        }
        graphics.endFill();
    }
}