# Multiple MC clip codes

**URL:** <https://forum.kirupa.com/t/multiple-mc-clip-codes/17830>\
**Category:** Uncategorized\
**Created:** [April 9, 2003, 8:07pm UTC](https://forum.kirupa.com/t/multiple-mc-clip-codes/17830 "2003-04-09T20:07:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric\_duvauchell](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@eric\_duvauchell](https://forum.kirupa.com/u/eric_duvauchell)\
**Post date:** [April 9, 2003, 8:07pm UTC](https://forum.kirupa.com/t/multiple-mc-clip-codes/17830/1 "2003-04-09T20:07:39Z")

</div>

## I have this code on a button that tells a mc to play when the variable fade is active.

## this code is in the timeline

next\_mc.onEnterFrame = function() {  
if (fade) {  
next\_mc.nextFrame();  
} else {  
next\_mc.prevFrame();  
}  
};

* * *

## on the button i have this code

on (rollOver) {  
\_root.fade = true;  
}  
on (rollOut, dragOut) {  
\_root.fade = false;  
}  
on (release) {  
nextFrame();  
play();  
}

* * *

What i want is to have multiple buttons use the fade variable, the only way i found to do this was to duplicte the timeline code everytime changing the name of the mc i want to target, and keeping the button code the same.

can i write it like this:

next\_mc.onEnterFrame = function() {  
previous\_mc.onEnterFrame = function() {  
if (fade) {  
next\_mc.nextFrame();  
previous\_mc.nextFrame();  
} else {  
next\_mc.prevFrame();  
previous\_mc.prevFrame();  
}  
};

or do i have to write this everytime:

next\_mc.onEnterFrame = function() {  
if (fade) {  
next\_mc.nextFrame();  
} else {  
next\_mc.prevFrame();  
}  
};

previous\_mc.onEnterFrame = function() {  
if (fade) {  
previous\_mc.nextFrame();  
} else {  
previous\_mc.prevFrame();  
}  
};

thanks to anyone who can simplify my fade in fade out code.

e
