# Event listener modular function

**URL:** <https://forum.kirupa.com/t/event-listener-modular-function/270814>\
**Category:** Uncategorized\
**Created:** [September 14, 2008, 7:01pm UTC](https://forum.kirupa.com/t/event-listener-modular-function/270814 "2008-09-14T19:01:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![prattmar](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@prattmar](https://forum.kirupa.com/u/prattmar)\
**Post date:** [September 14, 2008, 7:01pm UTC](https://forum.kirupa.com/t/event-listener-modular-function/270814/1 "2008-09-14T19:01:08Z")

</div>

hey guys, i am building my website and am trying to make my button functions modular. Right now i have the rollover effect working the way i want with this code…

function onResumeOver(evt:MouseEvent):void {  
resume\_btn.gotoAndPlay(“over”);  
};

resume\_btn.hit\_area\_mc.addEventListener(MouseEvent.ROLL\_OVER,onResumeOver);

function onResumeOut(evt:MouseEvent):void {  
resume\_btn.gotoAndPlay(“out”);  
};

resume\_btn.hit\_area\_mc.addEventListener(MouseEvent.ROLL\_OUT,onResumeOut);

But when i tried to make it modular for the otehr buttons im having errors with this code…

function buttonOver(button:MovieClip, evt:MouseEvent):void {  
button.gotoAndPlay(“over”);  
}

buttonOver(profile\_btn.hit\_area\_mc, addEventListener(MouseEvent.ROLL\_OUT,buttonOver));  
buttonOver(downloads\_btn.hit\_area\_mc, addEventListener(MouseEvent.ROLL\_OUT,buttonOver));  
buttonOver(resume\_btn.hit\_area\_mc, addEventListener(MouseEvent.ROLL\_OUT,buttonOver));  
buttonOver(contact\_btn.hit\_area\_mc, addEventListener(MouseEvent.ROLL\_OUT,buttonOver));

function buttonOut(button:MovieClip, evt:MouseEvent):void {  
button.gotoAndPlay(“out”);  
}

buttonOut(profile\_btn.hit\_area\_mc, addEventListener(MouseEvent.ROLL\_OUT,buttonOut));  
buttonOut(downloads\_btn.hit\_area\_mc, addEventListener(MouseEvent.ROLL\_OUT,buttonOut));  
buttonOut(resume\_btn.hit\_area\_mc, addEventListener(MouseEvent.ROLL\_OUT,buttonOut));  
buttonOut(contact\_btn.hit\_area\_mc, addEventListener(MouseEvent.ROLL\_OUT,buttonOut))

Does anyone see where my problem is? and or a solution.

Thanks
