2 import flash.utils.Endian;
3 import flash.utils.ByteArray;
6 public function Output() : void {
7 this.b = new ByteArray();
8 this.b.endian = Endian.LITTLE_ENDIAN;
10 protected var b : ByteArray;
11 public function write(str : String) : void {
12 this.b.writeUTFBytes(str);
14 public function writeBinary(b : ByteArray) : void {
17 public function writeChar(c : int) : void {
20 public function writeInt32(i : int) : void {
23 public function writeUInt32(i : int) : void {
24 this.b.writeUnsignedInt(i);
26 public function writeDouble(f : Number) : void {
27 this.b.writeDouble(f);
29 public function writeUInt16(x : int) : void {
30 if(x < 0 || x > 65535) throw "Overflow";
31 this.writeChar(x & 255);
32 this.writeChar(x >> 8);
34 public function writeUInt24(x : int) : void {
35 if(x < 0 || x > 16777215) throw "Overflow";
36 this.writeChar(x & 255);
37 this.writeChar((x >> 8) & 255);
38 this.writeChar(x >> 16);
40 public function writeInt24(x : int) : void {
41 if(x < -8388608 || x > 8388607) throw "Overflow";
42 if(x < 0) this.writeUInt24(16777216 + x);
43 else this.writeUInt24(x);
45 public function writeInt8(c : int) : void {
46 if(c < -128 || c > 127) throw "Overflow";
47 this.writeChar(c & 255);
49 public function getBytes() : ByteArray {