Flash actionscript 3.0: how to display the external "XML" file in flash AS 3.0

how to display the external "XML" file in flash AS 3.0

Posted by Sankar.G | Posted in | Posted on 11:29 PM

var externalXML:XML=new XML;
var loader:URLLoader=new URLLoader();
var urlrequest:URLRequest=new URLRequest("Data.xml");
loader.load(urlrequest);
loader.addEventListener(Event.COMPLETE,one);
var rows:Number;
var array:Array=new Array();
function one(e1:Event):void
{
externalXML=new XML(loader.data);
rows=externalXML.Employee.Employee_Data.length();
for(var i:uint;i< rows;i++) { array.push({name_arr:externalXML.Employee.Employee_Data[i].@ Names,age_arr:externalXML.Employee.Employee_Data[i].@ Age,id_arr:externalXML.Employee.Employee_Data[i].@Id}); } display(); } function display():void { names.text=ages.text=ids.text=" "; for each(var arr in array) { names.appendText(arr.name_arr+"\n"); ages.appendText(arr.age_arr+"\n"); ids.appendText(arr.id_arr+"\n"); } } arr1_btn.addEventListener(MouseEvent.CLICK,two); arr2_btn.addEventListener(MouseEvent.CLICK,three); function two(e2:MouseEvent):void { array.sortOn("name_arr",array.DESCENDING); display(); } function three(e3:MouseEvent):void { array.sortOn("age_arr",array.DESCENDING|array.NUMERIC); display(); } create 3 text box and name it as names,ages,ids and create 2 buttons and name it as arr1 & arr2 to arrange the values in decending order below we have XML file store the XML file near to the flash file and Name it as Data.xml < Datas>
< Employee>
< Employee_Data Names="a" Age= "10" Id= "13" />
< Employee_Data Names="g" Age= "12" Id= "523" />
< Employee_Data Names="e" Age= "55" Id= "63" />
< Employee_Data Names="w" Age= "22" Id= "403" />
< Employee_Data Names="y" Age= "24" Id= "293" />
< Employee_Data Names="q" Age= "66" Id= "883" />
< Employee_Data Names="o" Age= "97" Id= "813" />
< Employee_Data Names="z" Age= "13" Id= "723" />
< /Employee>
< /Datas>

Comments (0)