XML Shortcuts helps to access the XMLNodes with ease. You may read my previous post which compares the XMLShortcuts with XPath from XFactor Studio, XML to Object Prototype, and XMLNode easy access by tatsuo kato

Here is a example file, that shows how you can use XMLShortcuts in your MTASC projects.

[cc lang=”actionscript3″] class XMLShortcutsExample { function XMLShortcutsExample () { //Activate the XML Shortcuts XMLShortcuts.activate (); //Create an XML Object //Note: Avoid declaring as XML var my_xml = new XML () //ignoreWhite=true is not a must for XML Shortcuts, but it can improve performance //for the sake of display we ignore it here //_xml.ignoreWhite=true; my_xml.onLoad = function (success) { if (success) { _root.t1_txt.text += “Original XML:n” + this; _root.t2_txt.text += “my_xml.english.a = ” + my_xml.english.a + “rn”; _root.t2_txt.text += “my_xml.english.a_1 = ” + my_xml.english.a_1 + “rn”; _root.t2_txt.text += “my_xml.english.$b = ” + my_xml.english.$b + “rn”; _root.t2_txt.text += “my_xml.english.c._word = ” + my_xml.english.c._word + “rn”; _root.t2_txt.text += “my_xml.english.c.__text = ” + my_xml.english.c.__text + “rn”; _root.t2_txt.text += “my_xml.english.a_1.nodeIndex = ” + my_xml.english.a_1.nodeIndex + “rn”; _root.t2_txt.text += “my_xml.english.c.rootNode instanceof XML = ” + (my_xml.english.c.rootNode instanceof XML) + “rn”; } } //Load the XML my_xml.load (“XMLShortcutsExample.xml”); var tf : TextFormat = new TextFormat (); tf.font = “Courier”; //Create a TextFied to display _root.createTextField (“t1_txt”, 0, 0, 0, 300, 400); _root.t1_txt.text = “XMLShortcutsExample:nn”; _root.t1_txt.setNewTextFormat (tf); _root.createTextField (“t2_txt”, 1, 300, 0, 500, 400); _root.t2_txt.text = “XMLShortcuts Usage:nn”; _root.t2_txt.setNewTextFormat (tf); _root.t2_txt.background = true; _root.t2_txt.backgroundColor = 0xDDDDDD; } static function main () : Void { var app : XMLShortcutsExample = new XMLShortcutsExample (); } }

[/cc]


above script produces the swf below, when compiled using the following command
[cc lang=”actionscript3″] mtasc “XMLShortcutsExample.as” -swf “XMLShortcutsExample.swf” -frame 1 -header 800:400:12:FFFFFF -main

[/cc]