Variable change listener?

Hi All,

I’m just wondering if there is a way to listen to a variable for changes? I’ve seen that you can listen to a change in a component, but I’ve not found any examples of variables, is it possible?

This is what I have tried, to no avail…

var myVariable:Number = 0;

var myListener = new Object();
	myListener.change = function(change) {
	trace("variable changed");
};
myVariable.addEventListener("change", myListener);

I’m getting this error…


Error Scene=Scene 1, layer=Layer 2, frame=1:Line 188: Syntax error.
***myListener.change = function(change) {

Total ActionScript Errors: 1 Reported Errors: 1

I have also tried .onChange instead of just .change but get the same results.

I’m a flash newbie and I could really do with your help, thanks in advance. Emlyn