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

chase2Dでかんたん重力マウス

Ukiukiライブラリのサンプルコード
Get Adobe Flash player
by shohei909 09 Feb 2011
/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/esGr
 */

//Ukiukiライブラリのサンプルコード
package {
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.events.Event;
    import flash.geom.Point;
    import flash.display.Sprite;
    import org.libspark.ukiuki.Ukiuki;
    import org.libspark.ukiuki.ease.Elastic;
    [SWF(frameRate="60")];
    public class FlashTest extends Sprite {
        static public const NUM:int = 80;
        private var mouse:Point = new Point();

        public function FlashTest() { 
            addChild( new Bitmap( new BitmapData(465,465,false,0) ) );
            
            for( var i:int = 0; i<NUM; i++ ){
                var star:Star = new Star();
                star.x = Math.random() * 465;
                star.y = Math.random() * 465;
                star.blendMode = "add";
                Ukiuki.yoyo( star, {rotation:180 }, { time:Math.random()*60+30, repeat:-1, ease:Elastic.IN_OUT } )
                Ukiuki.chase2D( star, mouse, { gravity:30, inertia:0.99, outType:"cycle" }, {x:-10, y:-10}, {x:475, y:475} )
                addChild(star);
            }
            addEventListener( "exitFrame", onFrame )
        }
        private function onFrame( e:Event ):void {
            mouse.x = mouseX; mouse.y = mouseY;
        }
    }
}
import flash.display.Graphics;
import flash.display.Shape;

class Star extends Shape{
    static public const COLOR:Array = [0xFF6767,0x6767FF,0x67FF67,0x55FFFF,0xFFFF55,0xFF55FF];
    static public const R:Number = 11;
    function Star(){
        var g:Graphics = graphics;
        g.beginFill( COLOR[int(Math.random()*COLOR.length)]  );
        g.moveTo( 0, -R )
        for( var i:int = 0; i < 10; i++ ){
            var dir:Number = Math.PI * 2 / 10 * ( i + 1 )
            var r:Number = i % 2 == 0 ? R/2 : R;
            g.lineTo( r*Math.sin(dir), -r*Math.cos(dir) );
        }
        g.endFill()
        alpha = 0.5;
    }
}