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: flash on 2010-2-21

Get Adobe Flash player
by foggy 14 Nov 2010
/**
 * Copyright foggy ( http://wonderfl.net/user/foggy )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/toZG
 */

// forked from termat's flash on 2010-2-21
package
{
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.BlurFilter;
    import flash.text.TextFormat;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.filters.BitmapFilterQuality;

    [SWF(width=480,height=480,backgroundColor=0x000000)]
    public class Practice30 extends Sprite {
        private var bmpdata:BitmapData;
        private var bmp:Bitmap;
        private var wx:Number;
        private var wy:Number;
        private var angle:Number;
        private var filter:BlurFilter;
        private const SPARK_COLOR:uint = 0x664020;
        
        public function Practice30() {
            bmpdata = new BitmapData(480, 480, false, 0x000000);
            bmp = new Bitmap(bmpdata);
            filter = new BlurFilter(16, 16, BitmapFilterQuality.HIGH);
            var mc:MovieClip = new MovieClip();
            mc.filters = [filter];
            mc.addChild(bmp);
            addChild(mc);
            angle = 0;
            for (var i:int = 0; i < 100; i++){
                var tf:TextFormat = new TextFormat();
                tf.size = 24*Math.random();
                tf.color = 0xff0000;
                tf.bold = true;
                var tt:TextImage = new TextImage("火", tf, 0xffffff);
                tt.update();
                var f:Fire = new Fire();
                f.addChild(tt);
                f.x = 480 * Math.random();
                f.y = 480 * Math.random();
                f.rotationZ = 360 * Math.random();
                f.size = tf.size as Number;
                this.addChild(f) ;
                this.addEventListener(Event.ENTER_FRAME, update);
            }
        }
        
        private function updateWind():void {
            angle += 5 * Math.random() - 2.5;
            angle = Math.min(Math.max(angle, -15), 15);
            wx = Math.cos(angle / 180 * Math.PI)+1;
            wy = Math.sin(angle / 180 * Math.PI);
        }
        
        private function update(e:Event):void {
            bmpdata.lock();
            bmpdata.draw(this);
            bmpdata.unlock();
            updateWind();
            for (var i:int = 1; i < this.numChildren; i++) {
                var obj:Fire = this.getChildAt(i) as Fire;
                obj.y += 9.8 * 0.1667 * 0.1667 + wy;
                if (obj.y > 480) obj.y = obj.y - 480;
                if (obj.y < 0) obj.y = 480 + obj.y;
                obj.x += wx+obj.size/10;
                if (obj.x > 480) obj.x = obj.x - 480;
                if (obj.x < 0) obj.x = 480 + obj.x;
                obj.rotationZ += Math.random()*2;
                obj.update();
            }
        }
    }
}

import flash.display.GradientType;
import flash.display.MovieClip;
import flash.geom.Matrix;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Bitmap;
import flash.display.BitmapData;
class Fire extends MovieClip {
    private static const SPARK_COLOR:uint = 0x664020;
    private static const REFLECTION_COLOR:uint = 0xFF1800;
    private const radius:Number = 50;
    public var size:Number;
    
    public function update():void {
        graphics.clear();
        var rr:Number = radius - this.x / 4;
        if (rr < 0) return;
        var matrix:Matrix = new Matrix();
        matrix.createGradientBox(rr * 2, rr * 2, 0, 0, 0);
        graphics.beginGradientFill(GradientType.RADIAL, [ SPARK_COLOR, REFLECTION_COLOR ], [ 1, 0 ], [ 0, 255 ], matrix);
        graphics.drawCircle(0, 0, rr);
        graphics.endFill();
    }
}

class TextImage extends MovieClip {
    private var backGround:uint;
    private var str:String;
    private var format:TextFormat;
    
    public function TextImage(s:String, f:TextFormat, c:uint):void {
        str = s;
        backGround = c;
        format = f;
    }
    
    public function update():void {
        while (this.numChildren > 0) this.removeChildAt(this.numChildren - 1);
        var text:TextField = new TextField();
        text.defaultTextFormat = format;
        text.text = str;
        text.width = text.textWidth;
        text.height = text.textHeight;
        var mc_tmp:MovieClip = new MovieClip();
        mc_tmp.addChild(text);
        var bd:BitmapData = new BitmapData(text.textWidth + 2, text.textHeight + 2);
        bd.fillRect(bd.rect,backGround);
        bd.lock();
        bd.draw(mc_tmp);
        bd.unlock();
        var mc:MovieClip = new MovieClip();
        mc.addChild(new Bitmap(bd, "auto", true));
        mc.x = -text.textWidth/2;
        mc.y = -text.textHeight/2;
        addChild(mc);
    }
}