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

せまってくる3D Ball

Get Adobe Flash player
by tktr90755 27 Sep 2010
// forked from ll_koba_ll's 3D Ball
package
{

    import flash.display.*;
    import flash.events.Event;
    
    public class Ball3DTest extends MovieClip
    {
        public function Ball3DTest()
        {
            addEventListener (Event.ENTER_FRAME, enterFrameHandler);
        }
        private function enterFrameHandler (e:Event):void
        {
            var ball:Ball3D = new Ball3D();
            addChild(ball);
        }
    }
}


import flash.display.*;
import flash.events.*;
import flash.geom.*;

class Ball3D extends Sprite
{

    public function Ball3D()
    {
        addEventListener (Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event):void
    {
        removeEventListener (Event.ADDED_TO_STAGE, init);
        
        var ball:Sprite = new Sprite();
        
        var fillType:String = GradientType.RADIAL;
        var colors:Array = [0xFFFFFF, 0x333333];
        var alphas:Array = [1, 1];
        var ratios:Array = [0x00, 0xFF];
        var matr:Matrix = new Matrix();
        matr.createGradientBox(-250, -250, Math.PI/2, 100, 80);
        var spreadMethod:String = SpreadMethod.PAD;
        var interpolation:String = InterpolationMethod.RGB;
        ball.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod,interpolation);  
        ball.graphics.drawCircle(0,0,100);
        
        addChild(ball);
        ball.x = -ball.width;
        ball.y = -ball.height;
        
        //動き
        var cx:Number = stage.stageWidth / 2;
        var cy:Number = 0;
        var fl:Number = 20;
        var _x:Number = Math.random () * 3200 - 1600;
        var _y:Number = Math.random () * 400 - 200;
        var _z:Number = 1000;
        var scale:Number = 0;
        addEventListener (Event.ENTER_FRAME, function ():void {
            
                _y = 600;
                _z -= 30;
                scale = fl / (fl + _z);
                ball.x = _x * scale + cx;
                ball.y = _y * scale + cy;
                ball.scaleX = scale;
                ball.scaleY = scale;
                if (_z<=0)
                {
                    removeEventListener (Event.ENTER_FRAME, arguments.callee);
                    removeChild(ball);
                }
                
            }
        );
        
    }

}

//参考サイト http://www.mdn.co.jp/content/view/1138/88/