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

DotWind

//////////////////////////////////////////////////////////////////////////////
DotWind
砂が竜巻のような動きで舞い上がって、文字を構成し、
すべての文字が表示された後、文字が煙のように消えて行く
...ようにしたいの。
(現状は、砂が舞い上がってるだけ)
[竜巻のような動きは3Dっぽくない方がいい]
//////////////////////////////////////////////////////////////////////////////
Get Adobe Flash player
by ProjectNya 15 Jul 2010
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/q0Ym
 */

////////////////////////////////////////////////////////////////////////////////
// DotWind
//
// 砂が竜巻のような動きで舞い上がって、文字を構成し、
// すべての文字が表示された後、文字が煙のように消えて行く
// ...ようにしたいの。
// (現状は、砂が舞い上がってるだけ)
// [竜巻のような動きは3Dっぽくない方がいい]
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.events.Event;
    import flash.geom.Rectangle;

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

    public class Main extends Sprite {
        private var rect:Rectangle;
        private var canvas:BitmapData;
        private var wind:Wind;
        private static var dots:uint = 20;

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

        private function init():void {
            rect = new Rectangle(0, 0, 465, 465);
            canvas = new BitmapData(rect.width, rect.height, false, 0xFFFFFFFF);
            var bitmap:Bitmap = new Bitmap(canvas);
            addChild(bitmap);
            wind = new Wind(canvas);
            addEventListener(Event.ENTER_FRAME, draw, false, 0, true);
        }
        private function draw(evt:Event):void {
            wind.create(dots);
            canvas.lock();
            canvas.fillRect(canvas.rect, 0xFFFFFFFF);
            wind.blow();
            canvas.unlock();
        }

    }

}


import flash.display.Sprite;
import flash.display.BitmapData;
import flash.geom.Rectangle;


class Wind extends Sprite {
    private var canvas:BitmapData;
    private var rect:Rectangle;
    private var dots:Array;
    private static var acceleration:Number = 0.02;

    public function Wind(c:BitmapData) {
        canvas = c;
        init();
    }

    private function init():void {
        rect = canvas.rect;
        dots = new Array();
    }
    public function create(max:uint):void {
        for (var n:uint = 0; n < max; n++) {
            var px:Number = Math.random()*rect.width;
            var py:Number = rect.height;
            var power:Number = Math.random() + 0.5;
            var velocity:Number = Math.random() + 0.5;
            var angle:Number = (Math.random()*2 - 1)*Math.PI;
            var dot:Dot = new Dot(px, py, power, velocity, angle);
            dots.push(dot);
        }
    }
    public function blow():void {
        for (var n:uint = 0; n < dots.length; n++) {
            var dot:Dot = dots[n];
            dot.angle += Math.PI/180;
            dot.vx = dot.velocity*Math.cos(dot.angle);
            dot.vy += acceleration*dot.power;
            dot.vy *= 0.99;
            dot.x += dot.vx;
            dot.y -= dot.vy;
            canvas.setPixel(dot.x, dot.y, dot.rgb);
            if (dot.x < rect.left) dot.x += rect.width;
            if (dot.x > rect.right) dot.x -= rect.width;
            if (dot.y < rect.top) {
                dots.splice(n, 1);
                dot = null;
            }
        }
    }

}


class Dot {
    public var x:Number = 0;
    public var y:Number = 0;
    public var angle:Number = 0;
    public var vx:Number = 0;
    public var vy:Number = 0;
    public var power:Number = 1;
    public var velocity:Number = 1;
    public var rgb:uint = 0x000000;

    public function Dot(_x:Number, _y:Number, p:Number, v:Number, a:Number):void {
        x = _x;
        y = _y;
        power = p;
        velocity = v;
        angle = a;
    }

}