Embed XML with swf

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

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();
}
}
}
facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Leave a Comment

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

Disclaimer: All published content views of author.