> I was wondering if Flex/Actionscript allows you to create references 
> to object properties on the fly with a dynamically created string. 
 
Yes. If obj is an object and s is the String "foo", then obj[s] is
obj.foo.
 
- Gordon

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of tedgies
Sent: Friday, May 25, 2007 10:43 AM
To: [email protected]
Subject: [flexcoders] Treat a string as a reference to an object?



Hi,

I was wondering if Flex/Actionscript allows you to create references 
to object properties on the fly with a dynamically created string. 
For example i would like to add a new series to a chart series at 
runtime and dynamically create the reference to dataprovider (an 
httpservice) with a string.

var numJournals:String = new String;
numJournals = 3;
var series = chartC.series;
var dataXMLStr:String = new String;
var newSeries:LineSeries = new LineSeries;
dataXMLStr = "series" + numJournals + ".lastResult.item";
newSeries.dataProvider = dataXMLStr
....
series.push(newSeries)
chartC.series = series;

The problem is that on the 7th line above newSeries does not 
recognize dataXMLStr as a reference to my httpservice dataprovider. 
So is there a function i can use to make dataXMLStr appear as a 
reference to my dataprovider, e.g. so flex will read:

newSeries.dataProvider = series3.lastResult.item

thanks,
Ted



 

Reply via email to