# Why does this work? (onChanged)

**URL:** <https://forum.kirupa.com/t/why-does-this-work-onchanged/156353>\
**Category:** flash\
**Created:** [July 25, 2005, 11:54am UTC](https://forum.kirupa.com/t/why-does-this-work-onchanged/156353 "2005-07-25T11:54:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxdefinition](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@maxdefinition](https://forum.kirupa.com/u/maxdefinition)\
**Post date:** [July 25, 2005, 11:54am UTC](https://forum.kirupa.com/t/why-does-this-work-onchanged/156353/1 "2005-07-25T11:54:37Z")

</div>

Hi All,

Can someone tell me why this is not working…

I want to be able to track data changes and then call a function.

```auto

 
// New Object
cool = new Object();
cool.dog = 0;
 
// Create Listener
dataListener = new Object();
_root.cool.dog.addListener(dataListener);
dataListener.onChanged = function() {
trace("the data has changed");
};
 
// Button
buttonBtn.onPress = function() {
cool.dog++;
};
 
 

```

for now the button makes the changes, but in my application the data changes on a random event, so I need to monitor it.

Thanks people…

Codekill…
