Embed XML with swf

I never thought embedding of XML in an swf was so easy. Code below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.utils.ByteArray;

/**
* ...
* @author
*/

public class XMLEmbed extends Sprite {

[Embed(source="lesson.xml", mimeType="application/octet-stream")]
private static const DataXML:Class;

private var _dataXML:ByteArray;

public function XMLEmbed(){
_dataXML = new DataXML() as ByteArray;
var xml:XML = new XML(_dataXML);

var _t:TextField = new TextField();
addChild(_t);

_t.text = xml.toXMLString();
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *