flash on 2012-9-13

by mwelsh
♥0 | Line 23 | Modified 2012-09-13 17:46:29 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.text.TextField;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var tf:TextField = new TextField();
            addChild(tf);
            tf.height = 1000;
            tf.width = 1000;
            const NUM_ENTRIES:int = 64;
            for(var i:int = 0; i<NUM_ENTRIES; i++) {
                var a : Number = Math.cos(i * 2 * Math.PI / (NUM_ENTRIES-1));
                var n : int = int(a * 127.5 - 0.5);
                var nstr : String = uint(n).toString(2);
                if(nstr.length > 8)
                   nstr = nstr.substr(nstr.length - 8);
                else
                    while(nstr.length < 8) nstr = "0" + nstr; 
                 tf.appendText( "\t.byte %" + nstr + "\n");
            }

        }
    }
}