I want to generate combo boxes dynamically in Flex 3 with an ArrayCollection, having success until returning only one record

When my arraycollection returns more than one row, i have success generating my dynamic text fields and combo boxes. I am attaching code and screen shots.
private function skuOptionsHandler(event:ResultEvent):void
		{
			acOptionTypeName = event.result.options.optionTypeName as ArrayCollection;
			for(var i:int; i < acOptionTypeName.length; i++)
			{
				var optText:Text = new Text();
				optText.x = optTextX;
				optText.y = optTextY;
				details.addChild(optText);
				optTextY += 30;
				optText.text = acOptionTypeName[i].name + ": ";
				
				var optCombo:ComboBox = new ComboBox();
				optCombo.x = optComboX;
				optCombo.y = optComboY;
				details.addChild(optCombo);
				optComboY += 30;
				acOptionArray = event.result.options.optionTypeName[i].option as ArrayCollection;
				optCombo.dataProvider = acOptionArray;
				optCombo.labelField = "value";
				//optCombo.value = "id";
			}
		}

Open in new window

Untitled-1-0001-ac-that-works.jpg
Untitled-1-0002-ac-that-doesnt-w.jpg
rarid122481Asked:
Who is Participating?
 
moagriusConnect With a Mentor Commented:
when only one result is returned, it is returned as an ObjectProxy.

you just need to test if event.results.rows.row is an ArrayCollection or an ObjectProxy, then react appropriately.

the identical issue is referenced on livedocs:  http://livedocs.adobe.com/flex/3/html/help.html?content=dpcontrols_6.html - look near the bottom at the comments
0
 
rarid122481Author Commented:
when i debug, i complex string is returned instead of the needed arraycollection

result      mx.utils.ObjectProxy (@1aeefa19)      
      object      Object (@1af72769)      
      options      mx.utils.ObjectProxy (@1aeefc59)      
            object      Object (@1af90061)      
            optionTypeName      mx.collections.ArrayCollection (@1af5f081)      
                  [inherited]      
                  [0]      mx.utils.ObjectProxy (@1aeefce9)      
                  [1]      mx.utils.ObjectProxy (@1aeefd79)      
                  [2]      mx.utils.ObjectProxy (@1aeefe51)      
                  [3]      mx.utils.ObjectProxy (@1aeeff29)      
                        name      "Drill Bit Type"      
                        object      Object (@1af90c91)      
                        option      ComplexString (@e8b6311)      
                              id      294 [0x126]      
                              value      "French Backfill"      
0
 
rarid122481Author Commented:
thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.