posted on
27 04 2007
This post is more of a test of my code embedding tool for wordpress. It’s called iG:Syntax Hiliter and it works like a charm. I dig the text view along with the pretty color coded view.
So, about embedding an XML file in a flex swf…Here’s an example of embedding an XML file, then tracing out data at compile time via actionscript. The best part is the the XML is compiled into the swf, and you can access any of the XML file’s properties by accessing it via the singleton XML Manager.
[as][Embed(source=”myXMLFile.xml”,mimeType=”application/octet-stream”)]
public static const XMLFILE:Class;
public static const MY_XML : XML = setConst();
private var cache : Object
public var dataXML : XML;
private static function setConst():XML{
var ba:ByteArray = new XMLFILE() as ByteArray;
trace(”compiling”);
return new XML(ba.readUTFBytes(ba.length));
}
private static var model : XMLManager;
public static function getInstance() : XMLManager
{
if ( model == null )
{
model = new XMLManager();
}
return model;
}
public function XMLManager()
{
if ( model != null )
{
throw new Error( “Only one XML Manager instance should be instantiated” );
}
dataXML = MY_XML;
cache = new Object();
}
[/as]
source