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

Barcodes

"barcode function" = x*x*x % 300 - x*x*x % 150
Get Adobe Flash player
by signedvoid 17 Jun 2011
/**
 * Copyright signedvoid ( http://wonderfl.net/user/signedvoid )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/zRms
 */

package
{
    import flash.display.DisplayObject;
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.filters.DropShadowFilter;
    import flash.text.TextField;
    import flash.text.TextFormat;
    
    import flashx.textLayout.formats.TextAlign;
    [SWF(backgroundColor="0xefefef")]
    public class BarCodeFunctions extends Sprite
    {
        public function BarCodeFunctions()
        {
            super();
            addChild(barcodeLabel(130, "build", 50, 40, 20));
            addChild(barcodeLabel(230, "flash", 220, 70, -14));
            addChild(barcodeLabel(150, "online", 140, 190, 0));
        }

        private function barcodeLabel(n:int, text:String, x:Number, y:Number, rotation:Number):DisplayObject
        {
            var label:Sprite = new Sprite();
            label.x = x;
            label.y = y;
            label.rotationZ = rotation;
            var g:Graphics = label.graphics;

            //graphics
            label.filters = [new DropShadowFilter()];
            g.lineStyle(1, 0x7F7F7F);
            g.beginFill(0xFFFFFF);
            g.drawRoundRect(0, 0, 200, 120, 19, 19);
            g.endFill();

            //label
            var txt:TextField = new TextField();
            txt.defaultTextFormat = new TextFormat("Lucida Console", 12, 0, false, false, false, null, null, TextAlign.CENTER);
            txt.selectable = false;
            txt.text = text;
            txt.x = 10;
            txt.y = 8;
            txt.width = 180;
            label.addChild(txt);

            //barcode
            var n2:int = 2 * n;
            var i3:int;
            g.lineStyle(1, 0);
            var lx:int;
            for (var i:int = 0; i < 180; i++)
            {
                i3 = i * i * i;
                var bar:int = i3 % n2 - i3 % n;
                if (bar)
                {
                    lx = i + 10;
                    g.moveTo(lx, 30);
                    g.lineTo(lx, 110);
                }
            }
            return label;
        }
    }
}