Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic combo 1

Status
Not open for further replies.

thompom

Technical User
Dec 4, 2006
395
GB
hi - am new to flash8/actionscript so please bear with me

i want to add a combobox that gets its data from xml file
produced in asp.
so my xml output is
Code:
  <?xml version="1.0" encoding="utf-8" ?> 
- <data>
  <make id="11" make="Citroen" makecount="1" /> 
  <make id="13" make="Chevrolet" makecount="37" /> 
  <make id="18" make="Ford" makecount="3" /> 
  <make id="20" make="Hyundai" makecount="34" /> 
  <make id="28" make="Land Rover" makecount="2" /> 
  </data>

and i have added a combo called makecombo to a frame
and have added this script to the frame

Code:
var myData:XML = new XML ();
myData.ignoreWhite = true;
myData.load ("[URL unfurl="true"]http://localhost/sewardgroup/combo.asp");[/URL]
myData.onLoad = function (success:Boolean):Void
{
if (success)
{
var data:XMLNode = this.firstChild;
var children:Array = data.childNodes;
var numItems:Number = children.length;

for (var i:Number = 0; i < numItems; i++)
{
var child:XMLNode = children[i];
var id:String = child.attributes.id;
var make:String = child.attributes.make;
var makecount:String = child.attributes.makecount;
makecombo.addItem (id, make, makecount);
}
}
else
{
trace ("Error loading data");
}
};

but my combo is still unpopulated
any ideas welcome
many thanks M
 
..one more thing - i get no errors on movie test
 
> makecombo.addItem(id, make, makecount);

ComboBox.addItem() takes two parameters "label" and "data", not 3 parameters.

Your script does what you told to do - ComboBox with 11, 13, 18, 20 and 28 as labels.

Kenneth Kawamoto
 
many thanks - got it! heres a *

adjusted my label to incorporate makecount in the xml

my next task is to make a button that opens a url with
the id selected in the combo

" & id

any pointers welcome

thanks again
 
think im on right track - this displays the number that the item is in the list
Code:
on(release)
{
makeselect = (makecombo.selectedIndex);
trace(makeselect);
}

so i thought
Code:
makeselect = (makecombo.selectedItem);
would display the data - but i get [object object] in the trace window
do i need something called a listener?
 
Code:
...
makeselect = makecombo.selectedItem;
trace("makeselect.label: " + makeselect.label);
trace("makeselect.data: " + makeselect.data);
...
What do you get if you do the above?

Kenneth Kawamoto
 
thanks so much kenneth - this is sorted thanks
for getting me on the right track
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top