On Thu, Aug 14, 2008 at 6:19 AM, Fidel Viegas <[EMAIL PROTECTED]> wrote:
> On Thu, Aug 14, 2008 at 5:54 AM, grimmwerks <[EMAIL PROTECTED]> wrote:
>>
>> I've got a class that gets a JSON object - and within this JSON object
>> is a list of items.
>>
>> I'm trying to do what I think is very simple -- but I'm missing
>> something -- being able to bind a tilelist to an array of this
>> returned objects.items.
>>
>> I've tried manually parsing through these items and doing an
>> addItem(return.items[i]) into an arraycollection - but this doesn't
>> seem to be working at all.
>>
>> Any thoughts or examples please?
>
> Get the as3corelib (http://code.google.com/p/as3corelib/) and do the 
> following:
>
> import com.adobe.serialization.json.JSON;
>
> // get the results as JSON
> var results:String = String(httpService.lastResult);
>
> // decode them into an object
> var obj:Object = JSON.decode(results);
>
> // get the bindings as an array
> var test:Array = obj.results.bindings as Array;
>
> // create a collection that can be used by the data grid
> var arrayColl:ArrayCollection = new ArrayCollection(test);
>
> All the best,
>
> Fidel.
>

Sorry, let me correct that:


                        import mx.collections.ArrayCollection;
                        import mx.rpc.events.ResultEvent;
                        import com.adobe.serialization.json.JSON;
                        
                        private function onJSONLoad(event:ResultEvent):void
                        {
                                var rawData:String = String(event.result);
                                var arr:Array = (JSON.decode(rawData) as Array);
                                
                                var dp:ArrayCollection = new 
ArrayCollection(arr);
                                
                                grid.dataProvider = dp;
                        }

You can find the example in the samples directory. The code I posted
previously is somethin I used in another test.

All the best,

Fidel.

Reply via email to