# Code won't work on button?

**URL:** <https://forum.kirupa.com/t/code-wont-work-on-button/204340>\
**Category:** Uncategorized\
**Created:** [October 19, 2006, 12:36am UTC](https://forum.kirupa.com/t/code-wont-work-on-button/204340 "2006-10-19T00:36:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flash\_Man1](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Flash\_Man1](https://forum.kirupa.com/u/Flash_Man1)\
**Post date:** [October 19, 2006, 12:36am UTC](https://forum.kirupa.com/t/code-wont-work-on-button/204340/1 "2006-10-19T00:36:09Z")

</div>

hey all,

my code and listenersEvents won’t work on my button but when i put them in the frame they work?? why would this be??

here is my code:

```auto
var oListener:Object = new Object();
oListener.click = function(oEvent:Object):Void {
    trace(oEvent.target.selectedData);
    //q2_answer = oEvent.target.selectedData;
    if(oEvent.target.selectedData == "A snail"){
    q2_answer = "Q1 is correct"
} else {
    q2_answer = "Q1 is incorrect"
}
};
q1.addEventListener("click", oListener);

```
