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: Hello World!!!

/**
 * Copyright hacker_3ul82rys ( http://wonderfl.net/user/hacker_3ul82rys )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/jZWRk
 */

// forked from nitoyon's Hello World!!!
package {
    
    import flash.display.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.text.*;
    
    public class HelloWorld extends Sprite {
        private var bd:BitmapData = null;
        
        public function HelloWorld():void {
            var sp:Sprite = new Sprite();
            sp.graphics.beginFill(0xffffff, 0);
            sp.graphics.drawRect(0, 0, stage.stageWidth / 11, stage.stageHeight / 11);
            sp.graphics.endFill();
            //addChild(sp);
            
            var tf:TextField = new TextField();
            tf.width = sp.width;
            tf.textColor = 0x000000;
            tf.text = "Hello World!\nHello World!\nHello World!";
            tf.multiline = true;
            tf.autoSize = "left";
            var ts:TextFormat = new TextFormat();
            var size:int = 0;
            
            do {
                size++;
                ts.size = size;
                tf.setTextFormat(ts);
            } while(tf.textHeight < stage.stageHeight / 11 && tf.textWidth < stage.stageWidth / 11);
            
            if(tf.textHeight > stage.stageHeight / 11 + 2)
            {
                ts.size = size - 1;
                tf.setTextFormat(ts);
            }
            
            tf.x = sp.width * 0.5 - tf.textWidth * 0.5;
            tf.y = sp.height * 0.5 - tf.textHeight * 0.5;
            
            sp.addChild(tf);
            
            bd = new BitmapData(sp.width, sp.height, false, 0xffffff);
            bd.draw(sp);
            
            bd.applyFilter(bd, bd.rect, new Point(), new BlurFilter());
            bd.draw(sp);
            
            for(var i:int = 0; i < bd.width; i++) {
                for(var j:int = 0; j < bd.height; j++) {
                    var d:Sprite = new Diamond(bd.getPixel(i, j));
                    d.x = i * 10;
                    d.y = j * 10;
                    addChild(d);
                }
            }
        }
    }
}

import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Graphics;
import flash.geom.Point;

class Diamond extends Sprite {
    
    private var _g:Graphics = null;
    
    public function Diamond(color:uint):void {
        _g = this.graphics;
        _g.beginFill(color);
        drawDiamond(10, 10, 5, 5);
        _g.endFill();
    }
    
    public function drawLines(points:Vector.<Point>, isClose:Boolean = false):void {
        var length:int = points.length
        
        _g.moveTo(points[0].x, points[0].y);
        
        for(var i:int = 1; i < length; i++) {
            _g.lineTo(points[i].x, points[i].y);
        }
        
        if(isClose) {
            _g.lineTo(points[0].x, points[0].y);
        }
    }
    
    public function drawDiamond(width:Number, height:Number, x:Number = 0, y:Number = 0):void {
        var points:Vector.<Point> = getDiamondPoints(x, y, width, height);
        drawLines(points, true);
    }
    
    public function getDiamondPoints(x:Number, y:Number, width:Number, height:Number):Vector.<Point> {
        var points:Vector.<Point> = new Vector.<Point>();
        var wHalf:Number = width * 0.5;
        var hHalf:Number = height * 0.5;
        points.push(new Point(0 + x, -hHalf + y), new Point(wHalf + x, 0 + y), new Point(0 + x, hHalf + y), new Point(-wHalf + x, 0 + y));
        return points;
    }
}