topical media & game development
lib-as-core-XMLUtilDemo.mx
lib-as-core-XMLUtilDemo.mx
(swf
)
[ flash
]
flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Module
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
backgroundColor="#ffffff"
creationComplete="initApp()"
>
<mx:Script>
<![CDATA[
import com.adobe.utils.XMLUtil;
private var myXML:XML = XML(
"<node>"+
"<node label=\"group1\">"+
"<node label=\"user1\"/>"+
"<node label=\"user2\"/>"+
"<node label=\"user3\"/>"+
"</node>"+
"<node label=\"group2\"/>"+
"<node label=\"group3\"/>"+
"</node>"
);
private function initApp():void
{
resetXML();
}
private function onXMLTextChange(event:Event):void
{
if(XMLUtil.isValidXML(xmlText.text))
{
xmlTree.dataProvider = XML(xmlText.text).children();
}
else
{
xmlTree.dataProvider = null;
}
}
private function resetXML():void
{
xmlText.text = myXML.toString();
xmlTree.dataProvider = XML(xmlText.text).children();
}
]]>
</mx:Script>
<mx:HBox width="100%" height="100%">
<mx:TextArea id="xmlText" width="100%" height="100%" change="onXMLTextChange(event)"/>
<mx:Tree selectedIndex="0" id="xmlTree" width="100%" height="100%" labelField="@label"/>
<mx:VBox width="100%" height="100%">
<mx:Text text="isValidXML:{ XMLUtil.isValidXML(xmlText.text) }"/>
<mx:Button label="reset" click="resetXML()"/>
<mx:Text text="getPreviousSibling:{ '\n'+XMLUtil.getPreviousSibling(XML(xmlTree.selectedItem)).toXMLString() }"/>
<mx:Text text="current element:{'\n'+xmlTree.selectedItem.toXMLString()}"/>
<mx:Text text="getNextSibling:{'\n'+XMLUtil.getNextSibling(XML(xmlTree.selectedItem)).toXMLString()}"/>
</mx:VBox>
</mx:HBox>
</mx:Module>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.