Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-28-2006, 04:37 PM   #1
Navarone
Don
 
Navarone's Avatar
 
Join Date: Feb 2003
Location: Akron, Ohio USA
Posts: 2,077
Default [AS2] add item to comboBox via XML

I am trying to add items in my XML file to a comboBox component called nav_cb. I get 'undefined' in the comboBox. I am not sure I am doing this correctly.

Do I need a data provider? How do I accomplish this?
ActionScript Code:
var myList:XML = new XML(); myList.ignoreWhite = true; var showText = 0; myList_ar = new Array(); myList.onLoad = function(success) {     if (success) {         trace("loaded");         var rootList:XMLNode = this.firstChild;         var listLength = rootList.childNodes.length;         for (var i = 0; i<listLength; i++) {             myList_ar[i] = rootList.childNodes[i].childNodes[0].firstChild.nodeValue;             trace(rootList.childNodes[i].childNodes[0].firstChild.nodeValue)         }                 showList();     } else {         trace("not loaded");     } }; myList.load("myList.xml"); // function showList() {     var nav_items = myList_ar.length;     for (var i = 0; i<nav_items; i++) {         nav_cb.addItem({label:this["nav_items"+i]});     } }

My XML file looks like this:
PHP Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<furniture>
    <tables>
        <item>End Table</item>
        <item>Round Table</item>
    </tables>
    <chairs>
        <item>Chair</item>
        <item>Sofa</item>
    </chairs>    
</furniture>
__________________
Damn the torpedoes! Full speed ahead.
Navarone is offline   Reply With Quote
Old 08-28-2006, 04:48 PM   #2
Slowburn
[Invent:Design:Create]
 
Join Date: Sep 2002
Location: Toronto, ON
Posts: 2,068
Default

I think you just add the array as the data provider to the combo box.

But I don't use these components much.
__________________
o Please do a search before you post
o Please use the [ as][ /as] tag for your code (so we can read it clearly)
Slowburn is offline   Reply With Quote
Old 08-29-2006, 12:45 AM   #3
Navarone
Don
 
Navarone's Avatar
 
Join Date: Feb 2003
Location: Akron, Ohio USA
Posts: 2,077
Default

For beginers with XML and flash here is great little introduction that might help. Introduction to XML.
__________________
Damn the torpedoes! Full speed ahead.
Navarone is offline   Reply With Quote
Old 08-29-2006, 02:38 PM   #4
Navarone
Don
 
Navarone's Avatar
 
Join Date: Feb 2003
Location: Akron, Ohio USA
Posts: 2,077
Default

For some reason I can't get my videoList to appear in my combo box.
Can anyone see what I am missing?

ActionScript Code:
var videoList_xml:XML = new XML(); videoList_xml.ignoreWhite = true; var showText = 0; videoList_ar = new Array(); videoList_xml.onLoad = function(succes) {     if (succes) {         var rootList:XMLNode = this.firstChild;         var listLength = rootList.childNodes.length;         for (var i = 0; i<listLength; i++) {             videoList_ar[i] = rootList.childNodes[i].childNodes[0].firstChild.nodeValue;         }         showList();     } }; videoList_xml.load("videoList.xml"); // function showList() {     var num_videos = videoList_ar.length;        for (var i = 0; i<num_videos; i++) {         var tempVideo = videoList_ar[i];         trace(tempVideo);         nav_cb.dataProvider = ({label:tempVideo});     } }
__________________
Damn the torpedoes! Full speed ahead.
Navarone is offline   Reply With Quote
Old 02-04-2011, 02:42 AM   #5
finch124
Registered User
 
Join Date: Feb 2011
Posts: 2
Default populate it with xml

this is cool. but how do i populate this with xml?
finch124 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
getting selected item from combobox? gazzer82 Components 18 10-23-2006 02:52 AM
Changing the selected item in a combobox mcmcom Components 3 07-28-2006 11:42 AM
ComboBox setting the first item selected problem Ihou Components 1 01-21-2006 07:17 AM
combobox initial item combobox jerryj Components 0 01-09-2006 08:52 PM
How do you make a comboBox item sticky? allenshorter Components 3 02-02-2005 06:21 PM


All times are GMT. The time now is 01:22 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.