/* Custom XML class, loads a single node xml file into a TextField This also allows html simple formatting by using [brackets] in place of http://remixtechnology.com/view/as2-RMXml create a TextField object on the stage with an instance name, then create an RMXml object using this RMXml class with FileName and TextField as arguments. for example: there is a TextField object in _root named myTextField and an xml file in the xml/ directory named myContent.xml the xml file looks like this: (if the text starts with a [bracket], you need a leading space first [font size='15']My simple html content[/font] [br /] [i]examples are fun[/i] Line breaks like this will produce an extra empty line use [br /] for a single line break. [u][a href="http://remixtechnology.com"]links work too![/a][/u] so do [u]underlines[/u] and [b][u]nested tags[/u][/b] the end and the main.as class looks like this class main { function main(){ var myXML:RMXml = new RMXml("myContent",_root.myTextField); } } */ class RMXml extends XML{ private var txt:TextField; private var file:String; public function onLoad(success:Boolean){ if(success){ // replace [] with <> var txt_str:String = this.childNodes[1].firstChild.nodeValue; while(txt_str.indexOf("[",0) > 0){ txt_str = this.replace(txt_str,"[","<"); } while(txt_str.indexOf("]",0) > 0){ txt_str = this.replace(txt_str,"]",">"); } this.txt.html = true; this.txt.htmlText = txt_str; }else{ this.txt.text = "Content could not be loaded"; trace("RMXml could not load " + this.file); } } private function replace(look_str:String,find_str:String,replace_str:String):String{ var str:String = new String(); var result_str:Array = look_str.split(find_str); return result_str.join(replace_str); } public function RMXml(filename:String,txt_field:TextField){ super(); //cause XML is super this.file = filename; this.txt = txt_field; this.load(cfg.xmlDir + this.file + cfg.xmlExt); } }