# How to clean up this code

**URL:** <https://forum.kirupa.com/t/how-to-clean-up-this-code/187575>\
**Category:** flash\
**Created:** [April 30, 2006, 5:21pm UTC](https://forum.kirupa.com/t/how-to-clean-up-this-code/187575 "2006-04-30T17:21:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fourq2](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@fourq2](https://forum.kirupa.com/u/fourq2)\
**Post date:** [April 30, 2006, 5:21pm UTC](https://forum.kirupa.com/t/how-to-clean-up-this-code/187575/1 "2006-04-30T17:21:41Z")

</div>

Howdy folks!

I have an fla that uses the following AS:

```php
envisionblur._alpha = 100;
envisionblur.onRollOut = function(){
    this.onEnterFrame = function(){
       _root.qt_envision._alpha=0;	   
        this._alpha +=10;
        if(this._alpha >= 100){
            this._alpha = 100;
            this.onEnterFrame = null;
        }
    }
}

envisionblur.onRollOver = function(){
    this.onEnterFrame = function(){   
	_root.qt_envision._alpha=100;
        this._alpha -=10;
        if(this._alpha <= 0){
            this._alpha = 0;
            this.onEnterFrame = null;
        }
    }
}

innovateblur._alpha = 100;
innovateblur.onRollOut = function(){
    this.onEnterFrame = function(){
       _root.qt_innovate._alpha=0;
        this._alpha +=10;
        if(this._alpha >= 100){
            this._alpha = 100;
            this.onEnterFrame = null;
        }
    }
}
innovateblur.onRollOver = function(){
    this.onEnterFrame = function(){   
	_root.qt_innovate._alpha=100;
        this._alpha -=10;
        if(this._alpha <= 0){
            this._alpha = 0;
            this.onEnterFrame = null;
        }
    }
}

collaborateblur._alpha = 100;
collaborateblur.onRollOut = function(){
    this.onEnterFrame = function(){
        _root.qt_collaborate._alpha=0;      
        this._alpha +=10;
        if(this._alpha >= 100){
            this._alpha = 100;
            this.onEnterFrame = null;
        }
    }
}
collaborateblur.onRollOver = function(){
    this.onEnterFrame = function(){   
       _root.qt_collaborate._alpha=100;
        this._alpha -=10;
        if(this._alpha <= 0){
            this._alpha = 0;
            this.onEnterFrame = null;
        }
    }
}

performblur._alpha = 100;
performblur.onRollOut = function(){
    this.onEnterFrame = function(){
       _root.qt_perform._alpha=0;
        this._alpha +=10;
        if(this._alpha >= 100){
            this._alpha = 100;
            this.onEnterFrame = null;
        }
    }
}
performblur.onRollOver = function(){
    this.onEnterFrame = function(){   
	_root.qt_perform._alpha=100;
        this._alpha -=10;
        if(this._alpha <= 0){
            this._alpha = 0;
            this.onEnterFrame = null;
        }
    }
}

```

Basically, I have four MC’s that I want to fade onRollOver and onRollOut. As you can see, writing code for each MC is a rather convoluted way to achieve the effect. Can any of you AS gurus show me how to write the code as a function and apply it to all of the clips?

Thanks!
