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

forked from: LightBlink (3)

//////////////////////////////////////////////////////////////////////////////
LightBlink (3) like BcL
//////////////////////////////////////////////////////////////////////////////
/**
 * Copyright hacker_idMeta ( http://wonderfl.net/user/hacker_idMeta )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/xReQ
 */

// forked from ProjectNya's LightBlink (3)
////////////////////////////////////////////////////////////////////////////////
// LightBlink (3) like BcL
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;

    [SWF(backgroundColor="#990000", width="465", height="465", frameRate="30")]

    public class Main extends Sprite {
        private static var cols:uint = 8;
        private static var rows:uint = 6;

        public function Main() {
            //Wonderfl.capture_delay(1);
            init();
        }

        private function init():void {
            graphics.beginFill(0x006600);
            graphics.drawRect(0, 0, 465, 45);
            graphics.endFill();
            graphics.beginFill(0xCC9900);
            graphics.drawRect(0, 45, 465, 5);
            graphics.endFill();
            graphics.beginFill(0x990000);
            graphics.drawRect(0, 50, 465, 365);
            graphics.endFill();
            graphics.beginFill(0xCC9900);
            graphics.drawRect(0, 415, 465, 5);
            graphics.endFill();
            graphics.beginFill(0x006600);
            graphics.drawRect(0, 420, 465, 45);
            graphics.endFill();
            for (var n:uint = 0; n < cols*rows; n++) {
                var light:Light = new Light();
                light.x = 32 + 400/(cols - 1)*(n%cols);
                light.y = 82 + 300/(rows - 1)*uint(n/cols);
                addChild(light);
                var angle:Number = 360/cols/3*n;
                light.blink(angle, 10);
            }
        }

    }

}


import flash.display.Sprite;
import flash.display.Shape;
import flash.events.Event;
import flash.geom.Matrix;
import flash.display.GradientType;
import flash.geom.ColorTransform;

class Light extends Sprite {
    private var base:Sprite;
    private static var center:Number = 8;
    private static var radius:Number = 32;
    private static var color:uint = 0xFFFFFF;
    private var amplitude:Number;
    private var speed:Number;
    private static var radian:Number = Math.PI/180;
    private static var color1:uint = 0xFFFFFF;
    private static var color2:uint = 0xFF99CC;
    private var colorTrans:ColorTransform;

    public function Light() {
        base = new Sprite();
        addChild(base);
        draw();
        colorTrans = new ColorTransform(0, 0, 0, 1, 0, 0, 0, 0);
    }

    // メソッド
    public function blink(a:Number, s:Number):void {
        amplitude = a;
        speed = s;
        addEventListener(Event.ENTER_FRAME, blinking, false, 0, true);
    }
    private function blinking(evt:Event):void {
        amplitude -= speed;
        setRGB(Math.sin(amplitude*radian));
        base.transform.colorTransform = colorTrans;
    }
    private function setRGB(percent:Number):void {
        var r1:int = (color1 >> 16 & 0xFF);
        var g1:int = (color1 >> 8 & 0xFF);
        var b1:int = (color1 & 0xFF);
        var r2:int = (color2 >> 16 & 0xFF);
        var g2:int = (color2 >> 8 & 0xFF);
        var b2:int = (color2 & 0xFF);
        colorTrans.alphaMultiplier = 0.75 + 0.5*percent;
        colorTrans.redOffset = (r1 + r2)*0.5 + (r2 - r1)*0.5*percent;
        colorTrans.greenOffset = (g1 + g2)*0.5 + (g2 - g1)*0.5*percent;
        colorTrans.blueOffset = (b1 + b2)*0.5 + (b2 - b1)*0.5*percent;
    }
    private function draw():void {
        base.graphics.beginFill(color);
        base.graphics.drawCircle(0, 0, center);
        base.graphics.endFill();
        var colors:Array = [color, color];
        var alphas:Array = [0.6, 0];
        var ratios:Array = [0, 255];
        var matrix:Matrix = new Matrix();
        matrix.createGradientBox(radius*2, radius*2, 0, -radius, -radius);
        base.graphics.beginGradientFill(GradientType.RADIAL, colors, alphas, ratios, matrix);
        base.graphics.drawCircle(0, 0, radius);
        base.graphics.endFill();
    }

}