# Auto addEventListener("stateChange", listenerObject)

**URL:** <https://forum.kirupa.com/t/auto-addeventlistener-statechange-listenerobject/204180>\
**Category:** flash\
**Created:** [October 17, 2006, 7:08pm UTC](https://forum.kirupa.com/t/auto-addeventlistener-statechange-listenerobject/204180 "2006-10-17T19:08:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![seran128](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@seran128](https://forum.kirupa.com/u/seran128)\
**Post date:** [October 17, 2006, 7:08pm UTC](https://forum.kirupa.com/t/auto-addeventlistener-statechange-listenerobject/204180/1 "2006-10-17T19:08:26Z")

</div>

Code that I found.

[LIST=1]  
[_]I need to modify this code but have no idea where to start. First I need this code to update every half second. As it is currently written it only updates when I press a button. I am using it as a running time code for my movie.  
[_]I also need to be able to display the output to my flash app, it currently only outputs to my output box when testing.[/LIST]

```auto
import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.stateChange = function(eventObject:Object):Void {
trace(my_video.state + ": playhead time is: " + my_video.playheadTime);
};
my_video.addEventListener("stateChange", listenerObject);

```
