# Event listeners not firing consistently

**URL:** <https://forum.kirupa.com/t/event-listeners-not-firing-consistently/297733>\
**Category:** Uncategorized\
**Created:** [October 7, 2009, 7:57pm UTC](https://forum.kirupa.com/t/event-listeners-not-firing-consistently/297733 "2009-10-07T19:57:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vixiehd](https://avatars.discourse-cdn.com/v4/letter/v/6f9a4e/32.png) [@vixiehd](https://forum.kirupa.com/u/vixiehd)\
**Post date:** [October 7, 2009, 7:57pm UTC](https://forum.kirupa.com/t/event-listeners-not-firing-consistently/297733/1 "2009-10-07T19:57:10Z")

</div>

Hi,

Pretty much a complete n00b at flash and am stuck. Hoping someone will take pity 🎻

I have 9 buttons on my site which I wish to increase to 100% alpha when the users mouse rolls over each one, then have the alpha reduced to the original setting of 75% on rollout.

If I set the code below for 1 button it works just fine. However, if I repeat this code just changing the numbers for each button, it stops working once duplicated more than a couple of times.

Why does it stop working and how can I write this efficiently so it works for all 9 buttons?

Here is the code:-

addtocart1\_btn.addEventListener(MouseEvent.MOUSE\_OVER, fadeinaddtocart1);

function fadeinaddtocart1(event:Event):void  
{  
addtocart1\_btn.alpha = 1;  
}

addtocart1\_btn.addEventListener(MouseEvent.MOUSE\_OUT, fadeoutaddtocart1);

function fadeoutaddtocart1(event:Event):void  
{  
addtocart1\_btn.alpha = 0.75;  
}

addtocart2\_btn.addEventListener(MouseEvent.MOUSE\_OVER, fadeinaddtocart2);

function fadeinaddtocart2(event:Event):void  
{  
addtocart2\_btn.alpha = 1;  
}

addtocart2\_btn.addEventListener(MouseEvent.MOUSE\_OUT, fadeoutaddtocart2);

function fadeoutaddtocart2(event:Event):void  
{  
addtocart2\_btn.alpha = 0.75;

thanks 🙂
