# Listener not working

**URL:** <https://forum.kirupa.com/t/listener-not-working/214734>\
**Category:** Uncategorized\
**Created:** [January 31, 2007, 4:12pm UTC](https://forum.kirupa.com/t/listener-not-working/214734 "2007-01-31T16:12:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lariat1997](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@lariat1997](https://forum.kirupa.com/u/lariat1997)\
**Post date:** [January 31, 2007, 4:12pm UTC](https://forum.kirupa.com/t/listener-not-working/214734/1 "2007-01-31T16:12:30Z")

</div>

Hey all,

I have an external variable that changes. When it changes, I want to populate a listbox with a certain image.

Basically, when  
variable = 1, populate listbox with image1  
variable = 2, populate listbox with image2  
and so on.

I can do this with a button event, but I need it to happen when the variable changes and the user does not have to click on anything.

I’ve created a listener object that I cannot get to work. I am suspicious that the listener object does not work with my variable.  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#000000] **var** [/COLOR] \_iter = empty\_mc.[COLOR=#000080]iterator[/COLOR];[COLOR=#808080]_//empty\_mc.iterator;_[/COLOR]  
[COLOR=#000000] **var** [/COLOR] \_iterListener:[COLOR=#0000FF]Object[/COLOR] = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]Object[/COLOR]COLOR=#000000[/COLOR];

\_iterListener.[COLOR=#000080]onChange[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR]  
[COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]trace[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
\_iter.[COLOR=#0000FF]addListener[/COLOR]COLOR=#000000[/COLOR];  
[/LEFT]  
[/FONT]

Any advice?

Thanks in advance.
