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

サインポール [試作]

Get Adobe Flash player
by ProjectNya 03 Aug 2012
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ruUJ
 */

////////////////////////////////////////////////////////////////////////////////
// サインポール [試作]
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.StageScaleMode;
     import flash.display.StageAlign;

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

    public class Main extends Sprite {
        private var signpole:SignPole;

        public function Main() {
            //Wonderfl.capture_delay(1);
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            init();
        }

        private function init():void {
            signpole = new SignPole(24, 3);
            addChild(signpole);
            signpole.x = 232;
            signpole.y = 232;
            //
            signpole.start();
        }
        
    }

}


//////////////////////////////////////////////////
// SignPoleクラス
//////////////////////////////////////////////////

import flash.display.Sprite;
import flash.display.Shape;
import flash.events.Event;
import flash.geom.Matrix;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.filters.DropShadowFilter;

class SignPole extends Sprite {
    private var bw:uint = 16;
    private var bh:uint = 216;
    private var speed:Number = 2;
    private var stripe:Sprite;

    public function SignPole(w:uint, s:uint = 2) {
        bw = w;
        bh = w*13.5;
        speed = s;
        init();
    }

    private function init():void {
        drawBase();
        drawStripe();
        drawLight();
        drawHead();
        filters = [new DropShadowFilter(1, 90, 0x000000, 0.4, bw/4, bw/4, 1.5, 3, false, false, false)];
    }
    public function start():void {
        addEventListener(Event.ENTER_FRAME, update, false, 0, true);
    }
    public function stop():void {
        removeEventListener(Event.ENTER_FRAME, update);
    }
    private function update(evt:Event):void {
        stripe.y -= speed;
        if (stripe.y < -bw*4) {
            stripe.y += bw*4;
        }
    }
    private function drawBase():void {
        var base:Shape = new Shape();
        addChild(base);
        var colors:Array = [0x7F7F7F, 0xE6E6E6, 0xFFFFFF];
        var alphas:Array = [1, 1, 1];
        var ratios:Array = [0, 127, 204];
        var matrix:Matrix = new Matrix();
        matrix.createGradientBox(bw, bh, 0, -bw/2, -bh/2);
        base.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix, SpreadMethod.PAD, InterpolationMethod.RGB, 0);
        base.graphics.drawRect(-bw/2, -bh/2, bw, bh);
        base.graphics.endFill();
    }
    private function drawStripe():void {
        var container:Sprite = new Sprite();
        addChild(container);
        //
        stripe = new Sprite();
        container.addChild(stripe);
        for (var n:uint = 0; n < 12; n++) {
            var line:Shape = new Shape();
            stripe.addChild(line);
            line.y = bw*(2*n - 7);
            if (n%2 == 0) {
                line.graphics.beginFill(0x3333FF);
            } else {
                line.graphics.beginFill(0xCC0000);
            }
            line.graphics.moveTo(-bw/2, 0);
            line.graphics.lineTo(-bw/2, bw);
            line.graphics.lineTo(bw/2, 0);
            line.graphics.lineTo(bw/2, -bw);
            line.graphics.lineTo(-bw/2, 0);
            line.graphics.endFill();
        }
        var overlay:Shape = new Shape();
        container.addChild(overlay);
        overlay.graphics.beginFill(0x000000);
        overlay.graphics.drawRect(-bw/2, -bh/2, bw, bh);
        overlay.graphics.endFill();
        //
        stripe.mask = overlay;
    }
    private function drawLight():void {
        var light:Shape = new Shape();
        addChild(light);
        var colors:Array = [0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF];
        var alphas:Array = [0, 0.5, 0.5, 0];
        var ratios:Array = [0, 63, 127, 255];
        var matrix:Matrix = new Matrix();
        matrix.createGradientBox(bw/2, bh, 0, -bw/2, -bh/2);
        light.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix, SpreadMethod.PAD, InterpolationMethod.RGB, 0);
        light.graphics.drawRect(-bw/2, -bh/2, bw/2, bh);
        light.graphics.endFill();
    }
    private function drawHead():void {
        var top:Shape = new Shape();
        addChild(top);
        top.y = -bh/2;
        top.graphics.beginFill(0x000000);
        top.graphics.drawCircle(0, 0, bw/2*1.2);
        top.graphics.endFill();
        //
        var topmask:Shape = new Shape();
        addChild(topmask);
        topmask.y = -bh/2;
        topmask.graphics.beginFill(0x000000);
        topmask.graphics.drawRect(-bw, -bw, bw*2, bw);
        topmask.graphics.endFill();
        //
        top.mask = topmask;
        //
        var bottom:Shape = new Shape();
        addChild(bottom);
        bottom.y = bh/2;
        bottom.graphics.beginFill(0x000000);
        bottom.graphics.drawCircle(0, 0, bw/2*1.2);
        bottom.graphics.endFill();
        //
        var bottommask:Shape = new Shape();
        addChild(bottommask);
        bottommask.y = bh/2;
        bottommask.graphics.beginFill(0xFF0000);
        bottommask.graphics.drawRect(-bw, 0, bw*2, bw);
        bottommask.graphics.endFill();
        //
        bottom.mask = bottommask;
    }

}