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: dora muraken effect

@autoher : muraken (undefined Inc.)
// forked from ll_koba_ll's dora muraken effect
// forked from muraken's camera of undefined
// @autoher : muraken (undefined Inc.)

package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BitmapDataChannel;
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Matrix;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.media.Camera;
    import flash.media.Video;
    [SWF(width="465", height="465", backgroundColor="0xffffff", frameRate="40")]
    public class DoraMuraken extends Sprite {
        private var bmp:Bitmap;
        private const BMD_WIDTH:int = 240;
        private const BMD_HEIGHT:int = 240;
        private var baseColor:uint = 0xFFFFFF;
        private var baseBmd:BitmapData;
        private var editBmd:BitmapData;
        private var noiseBmd:BitmapData;
        private var sandstormBmd:BitmapData;
        private var sorce:DisplayObject;
        private var baseMatrix:Matrix;
        private var pointArray:Array;
        private var randArray1:Array;
        private var randArray2:Array;
        private var randNum1:Number;
        private var bmdUpNum:Number;
        private var video:Video;
        private var _bmp:Bitmap;
        private var camera_width:int;
        private var camera_height:int;

        public function DoraMuraken():void {
            var dora:Dora = new Dora();
            sorce = dora;
            bmp = new Bitmap();
            addChild(bmp);
            baseBmd = new BitmapData(BMD_WIDTH, BMD_HEIGHT, false, baseColor);
            editBmd = baseBmd.clone();
            noiseBmd = baseBmd.clone();
            sandstormBmd = baseBmd.clone();
            baseMatrix = new Matrix();
            pointArray = new Array(new Point(0, 0), new Point(0, 0), new Point(0, 0));
            randArray1 = new Array(Math.random() + 1, Math.random() + 1, Math.random() + 1);
            randArray2 = new Array(0, 0, 0);
            randNum1 =0.5;
            bmdUpNum = 0;
            bmp.bitmapData = noiseBmd;
            bmp.smoothing = true;
            bmp.visible = false;
            stage.addEventListener(Event.RESIZE, _onResize);
            _onResize(null);
            addEventListener(Event.ENTER_FRAME, upDate);
            bmp.visible = true;
            sorce.visible = false;
        }
        private function _onResize(e:Event):void {
            var W:Number = stage.stageWidth;
            var H:Number = stage.stageHeight;
            baseMatrix = new Matrix();
            baseMatrix.scale(BMD_WIDTH/W, BMD_HEIGHT/H);
            bmp.scaleX = W/BMD_WIDTH;
            bmp.scaleY = H/BMD_HEIGHT;
            bmp.x = bmp.y = 0;
        }
        private var _keyCnt:Number = 0;
        private function upDate(e:Event):void {
            var copy_bmd:BitmapData = baseBmd.clone();
            copy_bmd.draw(sorce, baseMatrix);
            editBmd = copy_bmd.clone();
            
            for (var i:int = 0; i < 3; i++) {
                if (randArray1[i] >= 1){
                    --randArray1[i];
                    randArray2[i] = Math.random() / 4 + 0.03;
                } 
                randArray1[i] = randArray1[i] + randArray2[i];
                _keyCnt += (48-_keyCnt) / 4;
                pointArray[i].x = Math.ceil(Math.sin(randArray1[i] * Math.PI * 2) * randArray2[i] * _keyCnt*2);
                pointArray[i].y = 0;
            }
            
            var keyNum:Number = 1*(Math.abs(pointArray[0].x) + Math.abs(pointArray[1].x) + Math.abs(pointArray[2].x) + 8) / 4;

            i = BMD_HEIGHT;
            while (i--){
                var offset:Number = Math.sin(i / BMD_HEIGHT * (Math.random() / 8 + 1) * randNum1 * Math.PI * 2)* 0.8 * keyNum * keyNum;
                editBmd.copyPixels(copy_bmd, new Rectangle(offset, i, BMD_WIDTH - offset, 1), new Point(0, i));
            }
            sandstormBmd.noise(int(Math.random() * 1000), 0, 255, 7, false);
            var sandNum:Number = 40;
            editBmd.merge(sandstormBmd, editBmd.rect, new Point(0,0), sandNum, sandNum, sandNum, 0);
            noiseBmd.copyChannel(editBmd, noiseBmd.rect, pointArray[0], BitmapDataChannel.RED, BitmapDataChannel.RED);
            noiseBmd.copyChannel(editBmd, noiseBmd.rect, pointArray[1], BitmapDataChannel.GREEN, BitmapDataChannel.GREEN);
            noiseBmd.copyChannel(editBmd, noiseBmd.rect, pointArray[2], BitmapDataChannel.BLUE, BitmapDataChannel.BLUE);
        }
    }
}


import flash.display.*;
class Dora extends Sprite
{
    public var sp:Sprite;
    private var centerX:Number;
    private var centerY:Number;
    
    public function Dora() {
        

        sp = new Sprite();
        sp.x = 300;
        sp.y = 200;
        addChild(sp);
        
        var head:Sprite = new Sprite();
        var w:Number = 94;
        var h:Number = 82;
        head.graphics.beginFill(0x6600CC); 
        head.graphics.moveTo(-w/2, 0);
        head.graphics.curveTo(-w/2+2, -h/2+1, 0, -h/2);
        head.graphics.curveTo(w/2-2, -h/2+1, w/2, 0);
        head.graphics.curveTo(w/2-1, h/2-1, 0, h/2);
        head.graphics.curveTo(-w/2+1, h/2-1, -w/2, 0);  
        head.graphics.endFill();
        
        var face:Sprite = new Sprite();
        face.y = 7;
        w = 86;
        h = 67;
        face.graphics.beginFill(0x000000); 
        face.graphics.moveTo(-w/2, 0);
        face.graphics.curveTo(-w/2+2, -h/2+1, 0, -h/2);
        face.graphics.curveTo(w/2-2, -h/2+1, w/2, 0);
        face.graphics.curveTo(w/2-1, h/2-1, 0, h/2);
        face.graphics.curveTo( -w/2+1, h/2 - 1, -w/2, 0);
        
        var lefteye:Sprite = new Sprite();
        lefteye.x = -17.5;
        lefteye.y = -35;
        drawOval(lefteye, 17, 19);
        
        var righteye:Sprite = new Sprite();
        righteye.x = 0.5;
        righteye.y = -35;
        drawOval(righteye, 17, 19);
        
        var nose:Sprite = new Sprite();
        nose.x = -5.5;
        nose.y = -20;
        drawOval(nose, 11, 9);
        
        var noseline:Sprite = new Sprite();
        noseline.graphics.lineStyle(1, 0xFFFFFF);
        noseline.graphics.moveTo( -0.5, -18);
        noseline.graphics.lineTo( -0.5, 24);
        
        var mouse:Sprite = new Sprite();
        mouse.graphics.lineStyle(1, 0xFFFFFF);
        mouse.graphics.moveTo( -31, 6);
        mouse.graphics.curveTo( -24, 24, 0, 24);
        mouse.graphics.curveTo(24, 24, 31, 6);
        
        var higeR:Sprite = new Sprite();
        higeR.graphics.lineStyle(1, 0xFFFFFF);
        higeR.graphics.moveTo( -16, -13);
        higeR.graphics.lineTo( -35, -16);
        higeR.graphics.moveTo( -17, -9);
        higeR.graphics.lineTo( -36, -9);
        higeR.graphics.moveTo( -16, -5);
        higeR.graphics.lineTo( -35, -2);
        
        var higeL:Sprite = new Sprite();
        higeL.graphics.lineStyle(1, 0xFFFFFF);
        higeL.graphics.moveTo( 16, -13);
        higeL.graphics.lineTo( 35, -16);
        higeL.graphics.moveTo( 17, -9);
        higeL.graphics.lineTo( 36, -9);
        higeL.graphics.moveTo( 16, -5);
        higeL.graphics.lineTo( 35, -2);
        
        sp.addChild(head);
        sp.addChild(face);
        sp.addChild(lefteye);
        sp.addChild(righteye);
        sp.addChild(nose);
        sp.addChild(noseline);
        sp.addChild(mouse);
        sp.addChild(higeR);
        sp.addChild(higeL);
    }
    
    private function drawOval(s:Sprite, w:Number, h:Number):void {
        s.graphics.beginFill(0xFFFFFF, 100); 
        s.graphics.moveTo(0, h/2);
        s.graphics.curveTo(0.5, 0.5, w/2, 0);
        s.graphics.curveTo(w-0.5, 0.5, w, h/2);
        s.graphics.curveTo(w-0.5, h-0.5, w/2, h);
        s.graphics.curveTo(0.5, h-0.5, 0, h/2); 
        s.graphics.endFill();
    }
    
}