Is there anyway I can see some code for this, when I create an
arraycollection I keep getting errors:
public var myList:ArrayCollection = new ArrayCollection();

                public function personJSON(event:ResultEvent):void
                {
                        var rawData:String = String(event.result);
                        var person:Object = JSON.decode(rawData);
                        trace(person[0].item1);
                        trace(person.length);
                        var x:Number;
                        
                        for(x=0;x<person.length;x++){
                                trace(person[x].item1);
//                              myList.push(person[x].item1);
                                myList.getItemAt(person[x].item1);

--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Arrays don't notify when you push items onto them, so you have to use
> ArrayCollection or use a temporary Array and assign it to myList
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of timgerr
> Sent: Thursday, May 01, 2008 11:42 AM
> To: [email protected]
> Subject: [flexcoders] Dynamic combobox from JSON request
> 
>  
> 
> Hello all, I have a Json request that I get from PHP backend. I am
> learning so I have created a dynamic list for a combo box. The
> problem is that when I press a button and it gets the data, I then go
> to the combo box and I see 1 entry. If I then select the combo box
> again I then will see all the entries. Not sure how to have all the
> entries show the first time I select the combo box. Here is my code:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
> <http://www.adobe.com/2006/mxml> "
> layout="absolute">
> <mx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
> import mx.rpc.events.ResultEvent;
> import com.adobe.serialization.json.JSON;
> 
> [Bindable]
> public var myList:Array = new Array();
> 
> public function personJSON(event:ResultEvent):void
> {
> var rawData:String = String(event.result);
> var person:Object = JSON.decode(rawData);
> trace(person[0].item1);
> trace(person.length);
> var x:Number;
> 
> for(x=0;x<person.length;x++){
> trace(person[x].item1);
> myList.push(person[x].item1);
> }
> trace(myList.length);
> }
> public function clearArray():void
> {
> myList = [];
> cmboOne.text = 'Choose';
> }
> ]]>
> </mx:Script>
> <mx:HTTPService id="personRequest"
> url="http://127.0.0.1/test/Class/InventoryRequest.php
> <http://127.0.0.1/test/Class/InventoryRequest.php> " 
> useProxy="false" method="GET" resultFormat="text" 
> result="personJSON(event)">
> <mx:request xmlns="">
> <getPerson>"true"</getPerson>
> </mx:request>
> </mx:HTTPService>
> <mx:Panel x="401" y="294" width="250" height="275" layout="absolute">
> 
> <mx:Button x="69" y="121" label="Get Info"
> click="personRequest.send()" id="send_btn"/>
> <mx:Button id="aryClear" click="clearArray()" label="Clear" x="78"
> y="151"/>
> </mx:Panel>
> <mx:ComboBox id="cmboOne" dataProvider="{myList}" rowCount="6"
> x="157" y="44"/>
> 
> </mx:Application>
> 
> Thanks,
> timgerr
>


Reply via email to