# How do I use a function I created?

**URL:** <https://forum.kirupa.com/t/how-do-i-use-a-function-i-created/255866>\
**Category:** flash\
**Created:** [March 27, 2008, 6:58pm UTC](https://forum.kirupa.com/t/how-do-i-use-a-function-i-created/255866 "2008-03-27T18:58:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Athrialix](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@Athrialix](https://forum.kirupa.com/u/Athrialix)\
**Post date:** [March 27, 2008, 6:58pm UTC](https://forum.kirupa.com/t/how-do-i-use-a-function-i-created/255866/1 "2008-03-27T18:58:30Z")

</div>

Hey, everyone

I’m trying to migrate some stuff to AS 3.0 but there are some things I can’t figure out how to do in 3.0.

I’ve found out how to declare a function (In AS 2.0, I used somename = function(){stuff})  
However, I can’t figure out how to make the function work as a 1-time thing (or in an “if” statement). I can do onEnterFrame, but not much else.

This code is in the frame of a movieclip on the stage.

```auto
//Variable Declarations
var t0:Number = getTimer()/1000;
var t:Number;
var thisy:Number = 0;
var vy:Number;
var vy0:Number = 0;
var y0:Number = 0;
var ymin:Number = 350;
// **Function Declarations**
//Gravity Variable Reset
**function resetytime (event:Event) {
    vy0 = (980 * t - vy0) *.5;
    t0 = getTimer () / 1000;
    y0 = ymin;
    if (vy0 < 20) {
        this.y = ymin;
        removeEventListener (Event.ENTER_FRAME, gravitate);
    }
}**
//Move Object downward
function gravitate (event:Event) {
    t = (getTimer () / 1000) - t0;
    thisy = 490 * t * t - vy0 * t + y0;
    if (thisy >= ymin) {
        **vy0 = (980 * t - vy0) *.5;
        t0 = getTimer () / 1000;
        y0 = ymin;
        if (vy0 < 20) {
            this.y = ymin;
            removeEventListener (Event.ENTER_FRAME, gravitate);
        }**
    }
    this.y = thisy;
}
//Actions
addEventListener (Event.ENTER_FRAME, gravitate);

```

link to the fla: [http://www.freewebs.com/gathalimay/Gravity.fla[URL=“http://www.freewebs.com/gathalimay/Gravity.fla”]](http://www.freewebs.com/gathalimay/Gravity.fla%5BURL=%22http://www.freewebs.com/gathalimay/Gravity.fla%22%5D)  
link to the swf: [http://www.freewebs.com/gathalimay/Gravity.swf](http://www.freewebs.com/gathalimay/Gravity.swf)

The code works as it is now, but I want to swap out the bolded parts in the “gravitate” function by dispatching the “resetytime” function instead. How can I do this?

Thanks in advance!
