A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: XML comboBox to text field?

  1. #1
    Senior Member
    Join Date
    Nov 2006
    Posts
    162

    XML comboBox to text field?

    Hi,
    I am going crazy on this problem, hopefully someone can help.

    I have a comboBox populated through XML. I want to transfer the selected item to a dynamic text field. After a few days and lots of hours... I cant figure this out.

    I have added my comboBox to the stage via the component wondow. Would that be my issue? Would it be best to set it through AS3?

    Here is my code..

    ComboBox prompt:
    Code:
    item.colour.prompt = xmllist2[p].colours.colour[0];
    XML:
    Code:
    <colours>
    		<colour>blue</colour>
    		<colour>burgundy</colour>
    		<colour>brown</colour>
    		</colours>
    Text field ( I have tried a thousand things like selected items, labels.. but there is something I am doing wrong because it does not work at all)

    Code:
    item.itemdesc.text = item.colour.selectedLabel;
    Any pointers to the right direction?

    Thanks!

  2. #2
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    Oh and maybe I should let you know how I get the info into the comboBox:

    PHP Code:
    var colorList:XMLList = new XMLList(xmllist2[p].colours.colour);
                
                        for(var 
    o:int 0colorList.length();o++){
                        
    item.colour.addItem({data:colorList[o],label:colorList[o]});
                        } 

  3. #3
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    Ok, here is some progress, but it still does not work.

    Hopefully someone can help now?

    I have added a function to handle the change of the combo box, but the issue is that it is not passing the updated variable to the text box...?? ANy idea why? please?

    Code:
    					var colourChoice:String = new String();
    					colourChoice = "";
    					
    					item.colour.addEventListener(Event.CHANGE, changeHandler);
    					
    					function changeHandler(event:Event):void {
      					 if(ComboBox(event.target).selectedItem.label != ""){
        				  colourChoice = (ComboBox(event.target).selectedItem.label.toString());					
    					  trace (colourChoice);
    					 
       					}
    					};
    					
    					item.itemdesc.text = colourChoice;

  4. #4
    Senior Member
    Join Date
    Nov 2006
    Posts
    162
    I still havent find the solution for this problem. I am really stuck..

    Any one?

    please?

  5. #5
    Member
    Join Date
    May 2011
    Posts
    39
    did you find it??

    i have the exact same dilemna now


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center