# Multiple effects with a custom class

**URL:** <https://forum.kirupa.com/t/multiple-effects-with-a-custom-class/306641>\
**Category:** flash\
**Created:** [March 18, 2010, 8:51pm UTC](https://forum.kirupa.com/t/multiple-effects-with-a-custom-class/306641 "2010-03-18T20:51:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fs\_tigre](https://avatars.discourse-cdn.com/v4/letter/f/edb3f5/32.png) [@fs\_tigre](https://forum.kirupa.com/u/fs_tigre)\
**Post date:** [March 18, 2010, 8:51pm UTC](https://forum.kirupa.com/t/multiple-effects-with-a-custom-class/306641/1 "2010-03-18T20:51:25Z")

</div>

Hi,

I created a class with some effects that I use most of the time, but I’m having a problem. What I have is a class, that contains three different effects, fade, scale and tint effects on a mouse over and they work fine when I do something like this.  
Class:

```auto
package standard.interactive{
    import com.greensock.*;
    
    import flash.display.*;
    import flash.events.*;

    public class Effects extends MovieClip {

        public var _mcFade:MovieClip;
        public var _mcSize:MovieClip;
        public var _mcTint:MovieClip;
        public var _fade:Number;
        public var _fadeDuration:Number;
        public var _scaleX:Number;
        public var _scaleY:Number;
        public var _scaleDuration:Number;
        public var _tintColor:uint;
        public var _tintDuration:Number;

        public function Effects() {
            trace("this is the constructor");
        }
        // Methods------------------------------------------------------
        public function resizeIt(mcSize:MovieClip,scaleDuration:Number,Xscale:Number,Yscale:Number) {
            _mcSize = mcSize;
            _scaleX = Xscale;
            _scaleY = Yscale;
            _scaleDuration = scaleDuration;
            _mcSize.addEventListener(MouseEvent.ROLL_OVER, resizing,false,0,true);
            _mcSize.addEventListener(MouseEvent.ROLL_OUT, resizing2,false,0,true);

        }

        public function fadeIt(mcFade:MovieClip,fadeDuration:Number,fade:Number) {
            _mcFade = mcFade;
            _fade = fade;
            _fadeDuration = fadeDuration;
            _mcFade.addEventListener(MouseEvent.ROLL_OVER, fading,false,0,true);
            _mcFade.addEventListener(MouseEvent.ROLL_OUT, fading2,false,0,true);

        }

        public function tintIt(mcTint:MovieClip,tintDuration:Number,tintColor:uint) {
            _mcTint = mcTint;
            _tintColor = tintColor;
            _tintDuration = tintDuration;
            _mcTint.addEventListener(MouseEvent.ROLL_OVER, tinting,false,0,true);
            _mcTint.addEventListener(MouseEvent.ROLL_OUT, tinting2,false,0,true);

        }

        //Functions ----------------------------------------------
        public function resizing(evt:MouseEvent):void {
            TweenLite.to(_mcSize,_scaleDuration,{scaleX:_scaleX,scaleY:_scaleY});
        }

        public function resizing2(evt:MouseEvent):void {
            TweenLite.to(_mcSize,1,{scaleX:1,scaleY:1});
        }
        //-------------------------------------------------------------------

        public function fading(evt:MouseEvent):void {
            TweenLite.to(_mcFade,_fadeDuration,{alpha:_fade});
        }
        public function fading2(evt:MouseEvent):void {
            TweenLite.to(_mcFade,1,{alpha:1});
        }
        //-------------------------------------------------------------------
        public function tinting(evt:MouseEvent):void {
            
            TweenMax.to(_mcTint, _tintDuration, {tint:_tintColor});
        }
        public function tinting2(evt:MouseEvent):void {
            TweenMax.to(_mcTint,1, {removeTint:true});                    
            
        }
    }
}

```

FLA file:

```auto
import standard.interactive.*;
var effect:Effects = new Effects();
effect.resizeIt(mc,.1,2,2);

```

The problem is when I want to apply the same effect to two different movieClips, the second overwrites the first one, so I need to create to instances of the class in order to make these two movieClips behaves differently.

Something like this:

```auto
import standard.interactive.*;
var effect:Effects = new Effects();
var effect2:Effects = new Effects();

effect.resizeIt(mc,.1,2,2);
effect2.resizeIt(mc2,2,3,3);

```

but what I really want is to be able to use the same effect in multiple movieClips without having to create an instance of the class for each movieClip.

Something like this:

```auto
import standard.interactive.*;
var effect:Effects = new Effects();

effect.resizeIt(mc,.1,2,2);
effect.resizeIt(mc2,2,3,3);
effect.resizeIt(mc3,2,3,3);
effect.resizeIt(mc4,2,3,3);
//bla, bla, bla

```

Is this possible? How complicate it would that be?

Thanks a lot!
