# Fading Multiple MovieClips

**URL:** https://forum.kirupa.com/t/fading-multiple-movieclips/25631
**Category:** flash
**Created:** [July 15, 2003, 4:06am UTC](https://forum.kirupa.com/t/fading-multiple-movieclips/25631 "2003-07-15T04:06:03Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![purplecow](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@purplecow](https://forum.kirupa.com/u/purplecow)
#### Post date: [July 15, 2003, 4:06am UTC](https://forum.kirupa.com/t/fading-multiple-movieclips/25631/1 "2003-07-15T04:06:03Z")

</div>

What I’m looking to do is have one button fade in/out fadeBox1\_mc  
and the other button fade in/out fadeBox2\_mc.

I can get one button to fade in and out the graphic with the following code:  
Main Timeline

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

Button:  
on (rollOver){  
this.fade=true;  
}  
on (rollOut,dragOut){  
this.fade=false;  
}

However when I attempt to create another button and make it fade in/out fadeBox2\_mc i’m unsuccessfull when adding another fade function with fadeBox2\_mc to the main timeline. What would be the most efficient way have having multiple buttons control \_mc fades? Thanks a ton!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 4:12am UTC](https://forum.kirupa.com/t/fading-multiple-movieclips/25631/2 "2003-07-15T04:12:07Z")

</div>

Sorry, I believe I posted this to the wrong place the first time.

What I’m looking to do is have one button fade in/out fadeBox1\_mc  
and the other button fade in/out fadeBox2\_mc.

I can get one button to fade in and out the graphic with the following code:  
Main Timeline

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

Button:  
on (rollOver){  
this.fade=true;  
}  
on (rollOut,dragOut){  
this.fade=false;  
}

However when I attempt to create another button and make it fade in/out fadeBox2\_mc i’m unsuccessfull when adding another fade function with fadeBox2\_mc to the main timeline. What would be the most efficient way have having multiple buttons control \_mc fades? Thanks a ton!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 4:36am UTC](https://forum.kirupa.com/t/fading-multiple-movieclips/25631/3 "2003-07-15T04:36:16Z")

</div>

You should define a variable for each MovieClip, something like this:  
[AS]// Frame Actions  
fadeMC = function() {  
if (this.fade) {  
this.nextFrame();  
} else {  
this.prevFrame();  
}  
};  
fadeBox1\_mc.onEnterFrame = fadeMC;  
fadeBox2\_mc.onEnterFrame = fadeMC;  
// Actions for Button controlling fadeBox1\_mc  
on (rollOver) {  
fadeBox1\_mc.fade = true;  
}  
on (rollOut) {  
fadeBox1\_mc.fade = false;  
}  
// Actions for Button controlling fadeBox2\_mc  
on (rollOver) {  
fadeBox2\_mc.fade = true;  
}  
on (rollOut) {  
fadeBox2\_mc.fade = false;  
}[/AS]  
That should work, I think. =)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 4:45am UTC](https://forum.kirupa.com/t/fading-multiple-movieclips/25631/4 "2003-07-15T04:45:18Z")

</div>

[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=28548](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=28548)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 4:49am UTC](https://forum.kirupa.com/t/fading-multiple-movieclips/25631/5 "2003-07-15T04:49:40Z")

</div>

You have made me such a happy man! Thanks a ton, worked perfectly!

Just so I can be sure…everything i’ve been learning has been by book and tutorial so i’m sure i’m missing a lot. Can you explain to me exactly how this part works:  
fadeMC = function() {  
if (this.fade) {  
this.nextFrame();  
} else {  
this.prevFrame();  
}  
};  
fadeBox1\_mc.onEnterFrame = fadeMC;  
fadeBox2\_mc.onEnterFrame = fadeMC;

Basically you’re saying “here is what fadeMC does and these \_mc follow that command”?

Thanks again!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 4:59am UTC](https://forum.kirupa.com/t/fading-multiple-movieclips/25631/6 "2003-07-15T04:59:18Z")

</div>

Yeah, the function is called by the Object when the assigned event occurs, in this case, the onEnterFrame handler. 😛

By the way, welcome to kirupa forum! 😉

**PS.** I just realized that you posted in both Flash MX and ActionScript sections, please do **not** crosspost! :-\

I’ll merge both threads.

**EDIT.** liam’s post looks funny. 😛
