philadendron
05-05-2011, 05:54 AM
Hi, I'm a student in an intro to flex dev class and I'm having trouble getting a dropdown to display the contents of an ArrayList. The ArrayList should be getting its data from an httpservice XML file. When I run the app, the dropdown is empty. Can you guys help me? I have to be able to do this for my final and it's driving me nuts. Here's the entire code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var usersArray:ArrayCollection = new ArrayCollection();
protected function userService_resultHandler(event:ResultEvent):void
{
usersArray = event.result.main.users;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<mx:HTTPService url="http://pr.uphero.com/users.xml" id="userService" result="userService_resultHandler(event)">
</mx:HTTPService>
</fx:Declarations>
<mx:Form x="76" y="61">
<mx:FormItem label="Label">
<s:DropDownList labelField="FirstName" dataProvider="{usersArray}"></s:DropDownList>
</mx:FormItem>
</mx:Form>
</s:Application>
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var usersArray:ArrayCollection = new ArrayCollection();
protected function userService_resultHandler(event:ResultEvent):void
{
usersArray = event.result.main.users;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<mx:HTTPService url="http://pr.uphero.com/users.xml" id="userService" result="userService_resultHandler(event)">
</mx:HTTPService>
</fx:Declarations>
<mx:Form x="76" y="61">
<mx:FormItem label="Label">
<s:DropDownList labelField="FirstName" dataProvider="{usersArray}"></s:DropDownList>
</mx:FormItem>
</mx:Form>
</s:Application>