Normally, you would turn your variable into a get/set function pair.
That is what [Bindable] meta data does for you.

 

Var _langType:String

Function get langType():String { return _langType}

Function set langType(value:String):void

{

            _langType = value;

            changeLangTxt();

}

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of derekyoussi
Sent: Friday, October 26, 2007 1:37 PM
To: [email protected]
Subject: [flexcoders] Detecting a variable change

 

Hey everybody!

I've been trying to figure out how to setup a listener to detect a
change in a variable. For instance, lets pretend we have a custom
component with the code below. The langType variable is bound to
another variable in the main application, and I want it to run the
changeLangTxt function whenever the langType variable changes. How do
I do this?

var langType:String = new String("english");
var helloMsg:String;

private function changeLangTxt():void{
if(langType == "spanish"){
helloMsg = "Hola"l
}
if(langType == "english"){
helloMsg = "Hi There"l
}
} 

 

Reply via email to