# Help with Function and EnterFrame

**URL:** <https://forum.kirupa.com/t/help-with-function-and-enterframe/248397>\
**Category:** flash\
**Created:** [January 7, 2008, 10:38pm UTC](https://forum.kirupa.com/t/help-with-function-and-enterframe/248397 "2008-01-07T22:38:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![orionstar](https://avatars.discourse-cdn.com/v4/letter/o/51bf81/32.png) [@orionstar](https://forum.kirupa.com/u/orionstar)\
**Post date:** [January 7, 2008, 10:38pm UTC](https://forum.kirupa.com/t/help-with-function-and-enterframe/248397/1 "2008-01-07T22:38:03Z")

</div>

Hello,

I have an enterFrame action that I use on a graphic:

```auto

    onClipEvent (enterFrame) {
        
            
        if (this._alpha >= 0) {
            this._alpha -= 2;
                } else {
            this._alpha = 0;
                }
                        
}

```

Because I want to use the above code more than a few times, I tried to make it a function.

```auto

function fadeOut() {  

 onClipEvent (enterFrame) {

        
            
        if (this._alpha >= 0) {
            this._alpha -= 2;
                } else {
            this._alpha = 0;
                }
}

```

But for some reason the function call does not work when I call it via an action on a graphic where initially the code worked when it was explicitly written and not called as a function.

```auto

onClipEvent (enterFrame) {
fadeOut();

}

```

What am I doing wrong?  
Any help would be greatly appreciated.
