flash on 2009-8-3

by awef
♥0 | Line 49 | Modified 2009-08-03 22:15:41 | MIT License
play

ActionScript3 source code

/**
 * Copyright awef ( http://wonderfl.net/user/awef )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/aJNR
 */

package  
{
    import flash.display.Sprite;
    import flash.filters.DropShadowFilter;
    import flash.filters.GlowFilter;
    import caurina.transitions.Tweener;
    
    public class main extends Sprite
    {
        private var w:int = 20;
        private var h:int = 20;
        private var cont:Sprite;
        
        public function main() 
        {
            cont = new Sprite();
            stage.addChild(cont);
            hogehoge();
        }
        
        private function hogehoge():void
        {
            stage.removeChild(cont);
            stage.addChild(cont = new Sprite());
            
            var sp:Sprite;
            for (var ix:int = 0; ix < w; ix++)
            {
                for (var iy:int = 0; iy < h; iy++)
                {
                    sp = new Sprite();
                    sp.x = (stage.stageWidth - stage.stageWidth / w) / 2;
                    sp.y = (stage.stageHeight - stage.stageHeight / h) / 2;
                    sp.z = 200;
                    sp.alpha = 0.6;
                    sp.graphics.beginFill(Math.random() * 0xFFFFFF);
                    sp.graphics.drawRect(0, 0, stage.stageWidth / w, stage.stageHeight / h);
                    sp.graphics.endFill();
                    sp.filters = [new DropShadowFilter(), new GlowFilter(0xFFFFFF, 0.6)];
                    Tweener.addTween(sp, {
                            x : ix / w * stage.stageWidth,
                            y : iy / h * stage.stageHeight,
                            z : 0,
                            time :  Math.random() * 2 + 1,
                            transition : "easeOutBack"
                        });
                    cont.addChild(sp);
                }
            }
            Tweener.addCaller(this, {onUpdate : hogehoge, time : 5, count : 1});
        }
    }
}