# Variable change listener?

**URL:** <https://forum.kirupa.com/t/variable-change-listener/144840>\
**Category:** Uncategorized\
**Created:** [April 17, 2005, 9:36pm UTC](https://forum.kirupa.com/t/variable-change-listener/144840 "2005-04-17T21:36:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![emlynmiles](https://avatars.discourse-cdn.com/v4/letter/e/ee7513/32.png) [@emlynmiles](https://forum.kirupa.com/u/emlynmiles)\
**Post date:** [April 17, 2005, 9:36pm UTC](https://forum.kirupa.com/t/variable-change-listener/144840/1 "2005-04-17T21:36:09Z")

</div>

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…

```auto
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
