flex 4.6
I am wondering how to access/change an object using a var passed to a function, for example if I have the id vg1Text, using
Application.application.vg1Text.text = txt2chg+":"+id2chg;
works but
Application.application.id2chg.text = txt2chg+":"+id2chg;
fails with
ReferenceError: Error #1069: Property id2chg not found
thx Art
module
public function chgFuncB1(txt2chg, id2chg):void {
Application.application.id2chg.text = txt2chg+":"+id2chg;
}
public function myFunc() : void{
chgFuncB1("New Text", "vg1Text");
}
Main Application
<s:VGroup id="vg1">
<s:Label id="vg1Text" text="Module loaded in Spark VGroup container:"/>
</s:VGroup>
To make this work, you can use the array notation (hope that’s the correct name for it). In this way, the String contained in the variable
id2chgcan be used as a property name.