WHAT'S NEW?
Loading...

combobox xml


import fl.controls.ComboBox;
import fl.data.DataProvider;
import flash.text.TextField;
import com.PustakaFlash.*;
var myComboBox:ComboBox = new ComboBox();
addChild(myComboBox);
var xml:XML;
var ld:loadXml = new loadXml("soal.xml");
myComboBox.move(427.3,15.35);
myComboBox.prompt = "Pilih Buah";
var textF:TextField = new TextField();
textF.text="No fruit selected"
addChild(textF);
textF.x=20
textF.y=20
textF.height=20
textF.width=100
textF.selectable=false;
ld.addEventListener(loadXml.COMPLETE, loadXmlCompleteHandler);
ld.addEventListener(loadXml.COMPLETE, loadXmlCompleteHandler);
ld.addEventListener(loadXml.ERROR, loadXmlErrorHandler);
ld.addEventListener(loadXml.SecurityError, loadXmlErrorHandler);
ld.addEventListener(loadXml.XML_ParseError, loadXmlErrorHandler);

function loadXmlCompleteHandler(e:Event):void
{
	xml = ld.data;
	var n:int = xml.number.length();
	ambildata(xml);
}
function loadXmlErrorHandler(e:Event):void
{
	trace("gakda");

}
var semuabuah:Array = [];
function ambildata(xml)
{
	for each (var buah in xml.number)
	{

		semuabuah.push({fn: buah.@urutan, ln: buah.@benar, pn: buah.@pertanyaan_id});
	}
	susundata();
}

function susundata():void
{

	myComboBox.dataProvider = new DataProvider ();

	for (var i:int = 0; i<semuabuah.length; i++)
	{

		myComboBox.addItem({label: semuabuah[i].fn + " " + semuabuah[i].ln + "\n", data: i});
	}
}


myComboBox.addEventListener(Event.CHANGE, onAddItem);

function onAddItem(event:Event):void {
textF.text="buah Number " + semuabuah[event.target.selectedItem.data].ln + "."
}