It looks like you're creating a String that looks like the code for the
object (i.e., "{ foo: 'bar' }"), and then casting that to Object. That
won't do what you want. The thing is still a String. You need to
actually programmatically create the Object.

Alternately, you can use the JSON.decode() methods in some library
(flexlib? or maybe corelib?) after programmatically constructing that
String, but that's a completely backwards way of doing it. In the AS2
days, I believe you could also have used eval() to do this, but it's not
hard to just construct the object itself programmatically.

The code you need to change is inside the loops you've omitted.

for each row:
var currItem:Object = {};

then inside that loop, for each property you want to graph:
currItem[element.name()] = element.valueOf();

and then outside that loop, but inside the per-row loop:
simpleData.addItem(currItem);

-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-----Original Message-----
From: john fisher <j...@jpfisher.net>
Reply-To: flexcoders@yahoogroups.com
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Creating an ArrayCollection object for
charting
Date: Thu, 08 Jan 2009 15:28:37 -0800

Can I define this better? Anybody got an idea?

john fisher wrote:
>
> 
> ################## This does not work: ################ 
> simpleData = new ArrayCollection([]);
> var st:String = new String();
> 
> #left out the loops here for clarity # 
> st += '{' + "name:" + '"' + statNode.name + '", ' ; 
> # looped here through data #
> var elname:String = element.name();
> var elvalue:Number = element.valueOf() ; 
> 
> st += elname + ":" + elvalue + ", " ; 
> var newst:String = st.slice(0, st.length-2 ); ////cuts off last white
> space and comma
> newst += '}' ;
> simpleData.addItem( newst as Object ) ;
> trace("ServerPopUp:makeChart simpledata: = " +
> ObjectUtil.toString(simpleData) );
> ServerPopUp:makeChart simpledata: =
(mx.collections::ArrayCollection)#0
> filterFunction = (null)
> length = 1
> list = (mx.collections::ArrayList)#1
> length = 1
> source = (Array)#2
> [0] "{name:"se2", inpps:2233, refresh:3000, outpps:7799,
> conns:2211, inbps:1144, inpkts:3322, outbps:2233, outpkts:4433,
> inbytes:4455, outbytes:5544, cps:6655}"
> uid = "9543B87D-14F5-0BC6-E2F0-B289C8EC32FC"
> sort = (null)
> source = (Array)#2
>
> #####
>
> thanks
> John
>
>
>
>
>
>
>
>
>
> 
> 
>
> 



 


Reply via email to