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

Graph Test

Get Adobe Flash player
by aasdb 06 Jul 2010
/**
 * Copyright aasdb ( http://wonderfl.net/user/aasdb )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/t3Vv
 */

package {
    import flash.display.Shape;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.display.Sprite;
    public class Graph extends Sprite {
        public function Graph() {
            var labels:Array = ["One", "Two", "Three"];
            var values:Array = [100, 200, 30];
            
            var margin:Number = 100;
            var h:Number = 30;
            
            for(var i:Number=0; i<labels.length; i++){
                var t:TextField = new TextField;
                var v:TextField = new TextField;
                var rect:Sprite = new Sprite;
                
                t.text = labels[i];
                t.y = i*h + margin;
                t.autoSize = TextFieldAutoSize.RIGHT;
                
                rect.graphics.beginFill(0xFF0000);
                rect.graphics.drawRect(0,0,values[i],h-10);
                rect.x = t.x + t.width + 30;
                rect.y = t.y - 5;
                
                v.text = String(values[i]);
                v.x = rect.x + rect.width + 10;
                v.y = t.y;
                
                addChild(t);
                addChild(v);
                addChild(rect);
            }
        }
    }
}