Re: [flexcoders] JSON as dataprovider
On Thu, Aug 14, 2008 at 2:50 PM, grimmwerks <[EMAIL PROTECTED]> wrote: > Ok I've actually had to do this slightly different - as there will be > a lot of flipping between items; what I'd hoped to do was something > like like a static var of 'db' as ArrayCollection and do a > db.removeAll() -- but when I've even manually parsed the var arr and > tried doing a db.addItem(arr[x]) it's not working... > What exactly are you trying to achieve? You have to be clearer on what you are after so that we can help you. Fidel.
Re: [flexcoders] JSON as dataprovider
Ok I've actually had to do this slightly different - as there will be a lot of flipping between items; what I'd hoped to do was something like like a static var of 'db' as ArrayCollection and do a db.removeAll() -- but when I've even manually parsed the var arr and tried doing a db.addItem(arr[x]) it's not working... On Aug 14, 2008, at 1:29 AM, Fidel Viegas wrote: > 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; > }
Re: [flexcoders] JSON as dataprovider
Excellent - thanks! On Aug 14, 2008, at 1:19 AM, Fidel Viegas 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. > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo > ! Groups Links > > >
Re: [flexcoders] JSON as dataprovider
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.
Re: [flexcoders] JSON as dataprovider
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.
[flexcoders] JSON as dataprovider
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?