# Same slideshow code with 3 differents containers?

**URL:** <https://forum.kirupa.com/t/same-slideshow-code-with-3-differents-containers/278108>\
**Category:** Uncategorized\
**Created:** [December 22, 2008, 5:18pm UTC](https://forum.kirupa.com/t/same-slideshow-code-with-3-differents-containers/278108 "2008-12-22T17:18:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpthali](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@jpthali](https://forum.kirupa.com/u/jpthali)\
**Post date:** [December 22, 2008, 5:18pm UTC](https://forum.kirupa.com/t/same-slideshow-code-with-3-differents-containers/278108/1 "2008-12-22T17:18:32Z")

</div>

Hi,

I found this very easy code on [actionscript.org](http://actionscript.org) but when i try to use it on 3 differents containers, only the last one works.  
Can you tell me what code i must add to this code, to use it with 3 differents clips on the same scene ?

Thanks

the code:

//: SETUP VARIABLES  
var maxVal = 5; // max number of fotos  
var oldVar = 0; // keep track of previous random number  
var newVar = 0; // used to load the next image  
var si = 3000; // interval variable

//: LOAD THE NEXT IAMGE  
function getImage() {  
newVar = Math.floor(Math.random() \* maxVal); // get random number  
if (newVar == oldVar) { // if number = old number…  
getImage(); // get a number  
} else { // else  
oldVar = newVar; // set old to new number  
selecBoutonB\_mc.loadMovie (“sec0-selection\_images/imagesB/selection\_boutonB\_image” + newVar + “.jpg”); // load the next image  
selecBoutonB\_mc.\_alpha = 0; // set its alpha to 0  
this.onEnterFrame = function () { // create loop  
if (selecBoutonB\_mc.\_width \> 0) { // check that the image has been loaded  
selecBoutonB\_mc.onEnterFrame = fadeIn; // start fading out  
delete this.onEnterFrame; // delete loop  
}  
}  
}  
}

//: FADE IN THE CURRENT MOVIECLIP  
function fadeIn () {  
if (this.\_alpha \<= 100) { // if the movieclips alpha is greater than 0  
this.\_alpha += 5; // reduce alpha by 5  
} else { // else  
this.\_alpha = 100; // reduce alpha to 0  
delete this.onEnterFrame; // delete handler  
si = setInterval(fadeOut, 2000); // after 2 seconds, fade out the movieclip  
}  
}

//: FADE OUT THE CURRENT MOVIECLIP  
function fadeOut () {  
clearInterval(si); // clear the interval variable  
selecBoutonB\_mc.onEnterFrame = function() { // create loop to fade out  
if (this.\_alpha \>= 0) { // if the movieclips alpha is greater than 0  
this.\_alpha -= 5; // reduce alpha by 5  
} else { // else  
this.\_alpha = 0; // reduce alpha to 0  
delete this.onEnterFrame; // delete handler  
getImage(); // load the next image  
}  
}  
}

// load first image  
getImage();
