Kappa effect

by freddy
♥0 | Line 49 | Modified 2011-11-09 01:18:00 | MIT License
play

ActionScript3 source code

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

package {
    import flash.events.Event;
    import flash.display.Shape;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var sh:Shape;
            var arr:Array = [];
            var alpha:Number = 0.3;
            function create():Shape {
                sh = new Shape();
                sh.graphics.beginFill(0x000000);
                sh.graphics.drawCircle(0, 0, 10);
                sh.y = 240;
                sh.alpha = 0.3;
                return sh;
            }
            
            sh = create();
            sh.x = 50;
            addChild(sh);
            arr.push(sh);
            
            sh = create();
            sh.x = 125;
            addChild(sh);
            arr.push(sh);
            
            sh = create();
            sh.x = 400;
            addChild(sh);
            arr.push(sh);
            
            arr.push(create());
            arr.push(create());
            arr.push(create());
            
            var t:int = 0;
            var i:int = 0;
            this.addEventListener(Event.ENTER_FRAME, function(e:Event):void {
                t++;
                if (t == 5) {
                    t = 0;
                    arr[i].alpha = alpha;
                    i++;
                    if (i == arr.length) {
                        i = 0;
                    }
                    arr[i].alpha = 1;

                }

            });

        }
    }
}