flash on 2013-11-21

by heroboy
♥0 | Line 35 | Modified 2013-11-21 12:22:18 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.*;
    import flash.text.*;
    import flash.utils.ByteArray;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var tf:TextField = new TextField();
            tf.text = "hello,world\nhello world\n";
            addChild(tf);
            tf.width = 300;
            tf.height = 400;
            tf.border = true;
            
            var buf:ByteArray = new ByteArray();
            //buf.writeUTF("hello,world");
            buf.writeByte(1);
            buf.writeByte(2);
            buf.writeByte(3);
            buf.writeByte(4);
            buf.writeByte(5);
            buf.writeByte(1);
            buf.writeByte(2);
            buf.writeByte(3);
            buf.writeByte(4);
            buf.writeByte(5);
            buf.compress('lzma');
            tf.text = byteArrayToString(buf);
        }
        private function byteArrayToString(buf:ByteArray):String
        {
            var arr:Array = [];
            for(var i:int=0;i<buf.length;++i)
                arr.push(buf[i]);
            return '['+arr.join(',') + ']';
        }
    }
}