Tuesday, December 22, 2009

AS3: Embedding XML files

If you have a XML file called myfile.xml. Code to include this would be:

[Embed(source="mfile.xml", mimeType="application/octet-stream")]
[Bindable]
private var my_file:Class;

function some_func():void {
var my_xml:XML = XML(new my_file);
}


my_xml now contains valid XML. You can now access stuff it like normal XML variables.

Got this from the comments in this post: http://dispatchevent.org/roger/embed-almost-anything-in-your-swf/