# Re-usable function triggered by multiple buttons

**URL:** <https://forum.kirupa.com/t/re-usable-function-triggered-by-multiple-buttons/284945>\
**Category:** flash\
**Created:** [March 25, 2009, 1:13pm UTC](https://forum.kirupa.com/t/re-usable-function-triggered-by-multiple-buttons/284945 "2009-03-25T13:13:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alan\_can](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@alan\_can](https://forum.kirupa.com/u/alan_can)\
**Post date:** [March 25, 2009, 1:13pm UTC](https://forum.kirupa.com/t/re-usable-function-triggered-by-multiple-buttons/284945/1 "2009-03-25T13:13:56Z")

</div>

Hello everyone, I have an AS3 newbie question that I hope someone may be kind enough to help me with. I am working on a presentation that has multiple scenes each having say 100 frames. Every 10 frames there is content on the stage, i.e. a ‘slide’. There are left and right arrow buttons to take the user of the presentation forward and backward - much like a powerpoint presentation.

Many of the ‘slides’ contain another button (instance name **infoBTN** ) that can be rolled-over, and when this happens an info bubble pops up to display some information in the form of a graphic (instance name **infoBubble** ).

This operation works fine for one button, but I don’t really want to have to call a new function and variable name and have new instance names on each subsequent frame that features a similar button with an identical operation.

My newbie question is how can I call the function just once and re-use it over and over again? There will only ever be one button of this nature on a given frame, if that helps.

This is the working code I have on the timeline for this particular frame:

```auto
// INFO BUTTON MOUSE EVENT
    
var fadeIn:Tween = new Tween(infoBubble, 'alpha', Regular.easeOut, 0, 1, 0.75, true);
fadeIn.stop();

infoBTN.addEventListener (MouseEvent.ROLL_OVER, infoOn);
infoBTN.addEventListener (MouseEvent.ROLL_OUT, infoOff);

function infoOn (event:MouseEvent):void {
    TransitionManager.start(infoBubble, {type:Zoom, direction:0, duration:0.75, easing: Elastic.easeOut});
    fadeIn.start();
    }

function infoOff (event:MouseEvent):void {
    var fadeOut:Tween = new Tween(infoBubble, 'alpha', Regular.easeOut, 1, 0, 0.3, true);
    fadeOut.start();
    }
    
stop();

```

Like I say I’m new to AS3, and a beginner with actionscript in general, so any help greatly appreciated. Cheers in advance.
