# Function with Arguments(Parameters)

**URL:** <https://forum.kirupa.com/t/function-with-arguments-parameters/254870>\
**Category:** flash\
**Created:** [March 16, 2008, 6:19pm UTC](https://forum.kirupa.com/t/function-with-arguments-parameters/254870 "2008-03-16T18:19:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![craig\_clayton](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@craig\_clayton](https://forum.kirupa.com/u/craig_clayton)\
**Post date:** [March 16, 2008, 6:19pm UTC](https://forum.kirupa.com/t/function-with-arguments-parameters/254870/1 "2008-03-16T18:19:38Z")

</div>

So basically what I want to do its make my code more reusable in a sense. The way I am coding things now when someone clicks on a button a timer function is called and then I have things animate off stage. After they are done I have timer function run which then loads in the new swf. Is there a way to make this happen in one function or one line of code instead of the way I am doing it now. I have to write the below code for every button instead of having to do it just once.

```auto

button.addEventListener(MouseEvent.CLICK, contentOut);

function contentOut (event:MouseEvent) {
    //Animations here
    howardTimer.start();
}

/*--- ANIMATION TIMER ---*/
var contentTimer:Timer = new Timer(1500,1);
contentTimer.addEventListener(TimerEvent.TIMER, contentLoad);

function contentLoad(event:TimerEvent) {
    removeChild(logo);
    removeChild(introTxt);
    trace("removed elements --- Now loading");
    var c = new CraigLoader( this );
    addChild( c );
    c.load( "howard-intro.swf" ); 
}

```
