# Apply function to different MC's simultaneously?

**URL:** <https://forum.kirupa.com/t/apply-function-to-different-mcs-simultaneously/260670>\
**Category:** flash\
**Created:** [May 18, 2008, 4:26pm UTC](https://forum.kirupa.com/t/apply-function-to-different-mcs-simultaneously/260670 "2008-05-18T16:26:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aveceva](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@aveceva](https://forum.kirupa.com/u/aveceva)\
**Post date:** [May 18, 2008, 4:26pm UTC](https://forum.kirupa.com/t/apply-function-to-different-mcs-simultaneously/260670/1 "2008-05-18T16:26:53Z")

</div>

Hey guys,

Sorry if this has been answered before - I have no idea where to begin with this so didn’t know what to search on the forum.

Basically:

1. I have 2 objects (Object1 and Object2)
2. I wish control them using the same code (the 1 set of code not 2)

Something like…

stage.addEventListener(Event.ENTER\_FRAME, Drop);  
var dropspeed = 3;

function Drop(event){

```
???.y = ???.y + dropspeed;

}

```

I suspect it MAY have something to do with creating a class that has both objects in it and applying the function to the class but I tried and Flash wouldn’t allow me to have 2 objects with the same class.

Like I said I pretty much have zero idea on how to go about doing this so if anyone can point me in some sort of direction that’d be awesomes

Thanks guys.

---

<div class="post-metadata">

**Author:** ![snickelfritz](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@snickelfritz](https://forum.kirupa.com/u/snickelfritz)\
**Post date:** [May 18, 2008, 7:55pm UTC](https://forum.kirupa.com/t/apply-function-to-different-mcs-simultaneously/260670/2 "2008-05-18T19:55:48Z")

</div>

Here’s a method I use quite often.  
Stage has three movieclips: button, mc1, mc2.  
The script basically causes mc1 and mc2 to scale-down on rollover and scale-up on rollout.

```auto
stop();
import gs.TweenMax;
import fl.motion.easing.*;

button.addEventListener(MouseEvent.MOUSE_OVER, rollover, false, 0, true);
button.addEventListener(MouseEvent.MOUSE_OUT, rollout, false, 0, true);

function rollover(event:MouseEvent):void {
	TweenMax.allTo([mc1, mc2], .5, {scaleX:.1, scaleY:.1, ease:Back.easeIn, overwrite:false});
}

function rollout(event:MouseEvent):void {
	TweenMax.allTo([mc1, mc2], .5, {scaleX:1, scaleY:1, ease:Elastic.easeOut, overwrite:false});
}

```
