But 'myObject' here should be an actual object and not a string a believe? However I did try both options, but that did not work.
On Fri, Aug 16, 2013 at 5:16 PM, Miguel Ferreira < [email protected]> wrote: > see this link: > > http://stackoverflow.com/questions/468925/in-actionscript3-how-do-you-get-a-reference-to-an-objects-class > Maybe this is enough for you? > var classRef:Class = getDefinitionByName(getQualifiedClassName(myObject)) > as Class; > I hope it helps. > Miguel. > > Date: Fri, 16 Aug 2013 17:09:12 +0530 > > Subject: How to get a class instance using string name? > > From: [email protected] > > To: [email protected] > > > > Hi there, > > > > Is there a way we can get a running instance in our application, by using > > it’s id as a String? > > > > > > > > For ex: > > > > I have a mxml line which is > > > > <mx:LinearAxis id="vAxis1" title="Growth%" > > labelFunction="percentageformatAxis" /> > > > > > > > > > > > > There is a data xml in which these instance names (vAxis1, vAxis2 …) > shall > > be declared: > > > > > > > > <doc> > > > > > > <row metricId="1" metricName="AUD" attribute="@AUD" checked="1" > > chartType="1" verticalAxis="vAxis1"> > > > > > > <row metricId="2" metricName="AUD Growth %" attribute="@AUDGrowth" > > checked="1" chartType="2" verticalAxis="vAxis2"/> > > > > > > </row> > > > > > > <row metricId="3" metricName="AUD MS" attribute="@AUDMSPerc" checked="0" > > chartType="2" verticalAxis="vAxis3"> > > > > > > <row metricId="4" metricName="AUD MS Growth %" > > attribute="@AUDMSGrowth" checked="0" chartType="1" > verticalAxis="vAxis4"/> > > > > > > </row> > > > > </doc> > > > > > > > > This data would be dynamic and I am trying to assign verticalAxis > attribute > > value to verticalAxis property of a column series at runtime: > > > > > > > > colSeries = *new* ColumnSeries(); > > > > colSeries.yField = > > String(metric.@attribute); > > > > colSeries.displayName = > > String(metric.@metricName); > > > > > > > > > > > > colSeries.verticalAxis = > > metric.@verticalAxis; //metric.@verticalAxis here would be a string. > But I > > have to reference the LinearAxis that I have declared on top, which is > > vAxis1. > > > > > > seriesArray.push(colSeries); > > > > > > > > Is there any way we can achieve that? > > > > > > > > getDefinitionByName() would just give be the class, but I need the > declared > > instance. > > > > > > > > > > > > Warm regards, > > > > Deepak > >
