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

Molten cheese

Wanted to call this liquid gold, but it looks more like cheese :P
/**
 * Copyright petewarrior ( http://wonderfl.net/user/petewarrior )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/lSzz
 */

package 
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.filters.BitmapFilterQuality;
    import flash.filters.BitmapFilterType;
    import flash.display.BitmapDataChannel;
    import flash.filters.BlurFilter;
    import flash.filters.BevelFilter;
    import flash.display.Shader;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.filters.ColorMatrixFilter;
    import flash.filters.ConvolutionFilter;
    import flash.filters.GradientBevelFilter;
    import flash.filters.GradientGlowFilter;
    import flash.geom.ColorTransform;
    import flash.geom.Matrix;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.text.TextField;
    import flash.display.BlendMode;
    
    /**
     * ...
     * @author Arya
     */
    public class Main extends Sprite 
    {
        //[Embed(source = 'snake.jpg')]
        private var Python:Class;
        private var bg:Bitmap;
        
        
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private var surface_top:BallSurface;
        private var surface_bottom:BallSurface;
        private var bitmap:Bitmap;
        private var bmp:BitmapData;
        private var bmpblur:BitmapData;
        private var fps:TextField;
        
        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            
            //bg = new Python();
            
            //addChild(bg);
            
            surface_top = new BallSurface();
            surface_top.visible = false;
            
            surface_top.x += 0;
            
            
            var filt:ColorTransform = new ColorTransform(1, 1, 1, 1, 255, 0, 255, 255);
            var filts:Array = new Array(filt);        
            //surface_top.transform.colorTransform = filt;
            
            trace(stage.width);
            
            bmp = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0);
            bmpblur = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0);
            
            
            bitmap = new Bitmap(bmp);
            

            
            //bitmap.filters = filts;
            
            
            addChild(surface_top);    
            addChild(bitmap);
            
            fps = new TextField();
            addChild(fps);
            
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
           
        }
        
      
        
        private function onEnterFrame(e:Event):void {
            //fps.text = stage.frameRate.toString();
            
            bmp.fillRect(new Rectangle(0, 0, stage.stageWidth, stage.stageHeight), 0);
            
            
            //var bmpblur:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0);
            bmpblur.fillRect(new Rectangle(0, 0, stage.stageWidth, stage.stageHeight), 0);
            
            var bgColor:uint     = 0xCCCCCC;
            var size:uint        = 5;
            var offset:uint      = 30;
            var distance:Number  = 4;
            var angleInDegrees:Number = 135; // opposite 45 degrees
            //var colors:Array     = [0xFFFFFF, 0xffc000, 0x000000];
            //var alphas:Array     = [0.6, 0.3, 0.8];
            //var ratios:Array     = [0, 128, 255];
            var colors:Array     = [0x000000, 0x000000, 0xFFFFFF];
            var alphas:Array     = [0.9, 0.0, 0.0];
            var ratios:Array     = [0, 120, 255];
            var blurX:Number     = 8;
            var blurY:Number     = 8;
            var strength:Number  = 1;
            var quality:Number   = BitmapFilterQuality.HIGH;
            var type:String      = BitmapFilterType.INNER;
            var knockout:Boolean = false;
            
            var zero:Point = new Point(0, 0);
            
            
            var bevel:GradientBevelFilter = new GradientBevelFilter(distance, angleInDegrees, colors, alphas, ratios, blurX, blurY, strength, quality, type, knockout);
            
            distance  = 4;
            angleInDegrees = 45;
            //colors   = [0x222200, 0x222200, 0xffff66, 0x445000];
            //alphas     = [0.1, 0.1, 0.75, 0.6];            
            // warna-warni
            //colors   = [0xFFFFFF, 0xFF0000, 0xccFF00, 0x00CCFF];
            //alphas     = [0, 0.2, 1, 1];
            //ratios     = [0, 10, 120, 255];
            colors   = [0x666633, 0xCC9933, 0xffff66, 0xCC9933];
            alphas     = [0.2, 0.2, 1, 1];
            ratios     = [0, 5, 120, 255];
            blurX     = 20;
            blurY     = 20;
            strength  = 0.5;
            quality   = BitmapFilterQuality.HIGH;
            type     = BitmapFilterType.INNER;
            knockout = false;
            
            var glow:GradientGlowFilter = new GradientGlowFilter(distance, angleInDegrees, colors, alphas, ratios, blurX, blurY, strength, quality, type, knockout);
            
            surface_top.balls.forEach(function(item:Ball, index:int, vector:Vector.<Ball>):void {
                //bmp.draw(item);
            });
            
            bmp.draw(surface_top);
            
            var bgbmp:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0);
            //bgbmp.draw(bg, null, null, BlendMode.NORMAL);
            bgbmp.draw(bmp, null, null, BlendMode.ALPHA, null, false);
            
            
            
            //bmpblur.draw(bgbmp);
            
            //bmp.colorTransform(bmp.rect, new ColorTransform(1, 1, 1, 1, 0, 0, 0, -50));
            //bgbmp.perlinNoise(30, 30, 2, 2011, true, true, 7, true);
            //bgbmp.copyChannel(bmp, bmp.rect, zero, BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);
            

            
            bmpblur.draw(bmp);
            
            
            
            var matrix:Array = new Array();
            matrix = matrix.concat([1, 0, 0, 0, 0xff]); // red
            matrix = matrix.concat([0, 1, 0, 0, 0xc0]); // green
            matrix = matrix.concat([0, 0, 1, 0, 0]); // blue
            matrix = matrix.concat([0, 0, 0, 0.8, 0]); // alpha            
            
            //bmpblur.applyFilter(bmpblur, bmpblur.rect, zero, new ColorMatrixFilter(matrix));
            bmpblur.applyFilter(bmpblur, bmpblur.rect, zero, glow);
            bmpblur.applyFilter(bmpblur, bmpblur.rect, zero, bevel);//new BevelFilter(2, 45, 0xffffff, 0.25, 0, 0.3, 7, 7, 8, 3));// BlurFilter(20, 20, 2));
            //bmpblur.applyFilter(bmp, bmp.rect, new Point(0, 0), new BlurFilter(1, 1, 1));
            
            bitmap.bitmapData = bmpblur;
            trace(surface_top.balls[1].x);
            
            //ripple.drawRipple(surface_top.balls[1].x, surface_top.balls[1].y, 1, 255);
            

            
        }

    }
}
    
import flash.display.Bitmap;
import flash.display.Shape;
import flash.events.Event;
import flash.events.TextEvent;
import flash.geom.Point;
import flash.text.TextField;
import flash.display.Sprite;

/**
 * ...
 * @author Arya
 */
class Ball extends Sprite 
{
    public var follow:Point;
    private var spd:TextField;
    private static var spread:Number = 40;
    private var rad:Number;
    
    public function Ball() 
    {
        super();
        rad = Math.random() * 20;
        this.graphics.beginFill(0xffc000);//0xcacaca);//0xffd000);
        this.graphics.drawCircle(0,0,rad);
        this.graphics.endFill();
        follow = new Point();
        spd = new TextField();
        spd.text = "0";
        //addChild(spd);
        
        addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }
    
    private var SPEED:Number;
    private var distance:Number;
    
    private function onEnterFrame(e:Event):void {
        
        distance = Math.pow(Math.pow(follow.y - this.y, 2) + Math.pow(follow.x - this.x, 2), 0.5);
        SPEED = 1 / Math.pow(distance / 10, 0.5) * 1000 * (0.2 + Math.random() * 0.8) + rad * 2;
        //spd.text = distance.toPrecision(3);//
        spd.text = SPEED.toPrecision(3);

        if (Math.abs(follow.x - this.x) > spread) {
            this.x += (follow.x - this.x) /Math.sqrt(Math.pow(follow.y - this.y, 2)+Math.pow(follow.x - this.x, 2)) * SPEED/ stage.frameRate;
        } else {
            //this.x = follow.x - 10 + Math.random() * 20;
            //this.x = this.x - 1 + Math.random() * 2;
        }
        if (Math.abs(follow.y - this.y) > spread) {
            this.y += (follow.y - this.y) / Math.sqrt(Math.pow(follow.y - this.y, 2) + Math.pow(follow.x - this.x, 2)) * SPEED/ stage.frameRate;
        } else {
            //this.y = this.y - 1 + Math.random() * 2;
        }
    }
    
    
}

import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;

/**
 * ...
 * @author Arya
 */
class BallSurface extends Sprite 
{
            
    private var surface_top:BallSurface;
    private var prevmouse:Point;
    public var balls:Vector.<Ball>;

    
    public function BallSurface() 
    {
        super();
        
        addEventListener(Event.ADDED_TO_STAGE, init);
    }
    
    private function init(e:Event):void {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        prevmouse = new Point(stage.mouseX, stage.mouseY);
        
        balls = new Vector.<Ball>();
        var i:Number;
        
        for (i = 0; i < 100; i++) {
            var ball:Ball = new Ball();
            var spread:Number = 100;
            ball.x = stage.stageWidth / 2 - 20 + Math.random() * 40;
            ball.y = stage.stageHeight / 2 - 20 + Math.random() * 40;
            ball.follow.x = stage.mouseX  - spread/2 + Math.random() * spread;
            ball.follow.y = stage.mouseY  - spread/2 + Math.random() * spread;
            
            balls.push(ball);
            addChild(ball);
        }
        
        trace("goat");
        
        trace(prevmouse.x + " " + prevmouse.y);
        
        stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
        
        stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }
    
    
    
    private function onMouseMove(e:MouseEvent):void {
        trace("mouse: " + mouseX + " " + mouseY);
        var spread:Number = 120;
        balls.forEach(function(item:Ball, index:int, vector:Vector.<Ball>):void {
            item.follow.x = stage.mouseX - spread / 2 + Math.random() * spread;
            item.follow.y = stage.mouseY - spread / 2 + Math.random() * spread;
            
            //item.follow.x += stage.mouseX - prevmouse.x;// - spread / 2 + Math.random() * spread;
            //item.follow.y += stage.mouseY - prevmouse.y;// - spread / 2 + Math.random() * spread;
            
        });
            prevmouse.x = stage.mouseX;
            prevmouse.y = stage.mouseY;
    }
    
    private function onEnterFrame(e:Event):void {
        
    }

}