<?xml
version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#841E1E,
#841E1E]" creationComplete="init()">
<mx:HTTPService id="htp"
result="Object"/>
<mx:ComboBox x="34"
y="32" id="cmb"
change="{textSelected.text = 'Selected item = '+cmb.selectedLabel}"></mx:ComboBox>
<mx:Text x="34" y="104" width="263"
height="82" color="#F9FDFE"
id="textSelected"/>
<mx:Script>
<![CDATA[
import
mx.rpc.events.ResultEvent;
public function init():void
{
htp.url = "country.xml";
htp.addEventListener(ResultEvent.RESULT,xmlLoaded);
htp.send();
}
public function
xmlLoaded(event:ResultEvent):void
{
var
str:String= event.result.root.country;
var
array:Array = str.split(",");
cmb.dataProvider =
array;
textSelected.text = 'Selected
item = '+array[0];
}
]]>
</mx:Script>
</mx:Application>
country.xml
<root>
<country> India
</country>
<country> USA </country>
<country> UK </country>
<country> Japan
</country>
<country> Spain
</country>
</root>
No comments:
Post a Comment