Creating a Byte Array : ByteArray « Development « Flash / Flex / ActionScript






Creating a Byte Array

 
package{
  import flash.display.Sprite;
  import flash.utils.ByteArray;  
  public class Main extends Sprite{
    public function Main(){

        var bytes:ByteArray = new ByteArray();
        bytes[0] = 256;
        trace(bytes[0]); // Outputs 0
        
        bytes.writeInt(1);
        trace(bytes[0] + ""+ bytes[1] + ""+ bytes[2] + ""+ bytes[3]);
    }
  }
}

        








Related examples in the same category

1.Write array to ByteArray
2.By default, private properties are not written when an object is serialized
3.Embedding Files as Binary Data
4.Embedding XML at compile time
5.Common Uses of Byte Arrays