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

LightBlink (1)

//////////////////////////////////////////////////////////////////////////////
LightBlink (1)
//////////////////////////////////////////////////////////////////////////////
Get Adobe Flash player
by ProjectNya 24 Aug 2010
    Embed
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bm3P
 */

////////////////////////////////////////////////////////////////////////////////
// LightBlink (1)
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;

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

    public class Main extends Sprite {
        private static var max:uint = 10;

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

        private function init():void {
            graphics.beginFill(0x000000);
            graphics.drawRect(0, 0, 465, 465);
            graphics.endFill();
            for (var n:uint = 0; n < max; n++) {
                var firefly:Firefly = new Firefly();
                firefly.x = 32 + 400/(max - 1)*n;
                firefly.y = 232;
                addChild(firefly);
                var angle:Number = 360/max*n;
                firefly.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 Firefly extends Sprite {
    private var base:Sprite;
    private static var center:Number = 5;
    private static var radius:Number = 20;
    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 = 0x0099FF;
    private static var color2:uint = 0x33CCFF;
    private var colorTrans:ColorTransform;

    public function Firefly() {
        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();
    }

}