Embedding XML at compile time : ByteArray « Development « Flash / Flex / ActionScript






Embedding XML at compile time

 
package {
  import flash.display.*;
  import flash.events.*;
  import flash.utils.ByteArray;

  public class EmbedXML extends Sprite {
    [Embed(source="embeds/data.xml", mimeType="application/octet-stream")]
    private var BinaryData:Class;

    public function EmbedXML (  ) {
      var byteArray:ByteArray = new BinaryData(  );

      var data:XML = new XML(byteArray.readUTFBytes(byteArray.length));

      trace(data.toXMLString(  ));
    }
  }
}

        








Related examples in the same category

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