# Flash image gallery trouble

**URL:** <https://forum.kirupa.com/t/flash-image-gallery-trouble/326729>\
**Category:** flash\
**Created:** [January 8, 2012, 5:06pm UTC](https://forum.kirupa.com/t/flash-image-gallery-trouble/326729 "2012-01-08T17:06:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iamgavin](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@Iamgavin](https://forum.kirupa.com/u/Iamgavin)\
**Post date:** [January 8, 2012, 5:06pm UTC](https://forum.kirupa.com/t/flash-image-gallery-trouble/326729/1 "2012-01-08T17:06:00Z")

</div>

Hi everyone. I followed this tutorial, [http://www.republicofcode.com/tutori…/imagegallery/](http://www.republicofcode.com/tutorials/flash/imagegallery/) for making an image gallery in flash.  
It looks great but the problem is that I’m using it as an image gallery page in an application with a number of other pages.  
When I run it on the gallery page it remains there even when i navigate to other pages. How can I make it disappear when I leave the gallery page? Thanks in advance!

Oh and here’s the code.

import mx.transitions.Tween;  
import mx.transitions.easing.\*;  
this.createEmptyMovieClip(“container”,1);  
var imagesNumber:Number = 9;  
var scrolling:Boolean = true;  
for (i=1; i\<=imagesNumber; i++) {  
container.attachMovie(“thumb”+i,“thumb”+i+"\_mc",i);  
myThumb\_mc = container[“thumb”+i+"\_mc"];  
myThumb\_mc.\_x = (i-1)\*myThumb\_mc.\_width;  
myThumb\_mc.\_y = (Stage.height-myThumb\_mc.\_height)/2  
myThumb\_mc.\_alpha=50;  
myThumb\_mc.largerImage = i;  
myThumb\_mc.onRollOver = function(){  
this.\_alpha=100;  
}  
myThumb\_mc.onRollOut = function(){  
this.\_alpha=50;  
}  
myThumb\_mc.onRelease = function(){  
this.\_alpha=50;  
for (i=1; i\<=imagesNumber; i++) {  
var myClip = container[“thumb”+i+"\_mc"];  
myClip.enabled = false;  
}  
scrolling = false;  
\_root.attachMovie(“gallery”+this.largerImage,“large\_mc”,2);  
large\_mc.\_x = (Stage.width - large\_mc.\_width)/2;  
large\_mc.\_y = (Stage.height - large\_mc.\_height)/2;  
new Tween(large\_mc,"\_alpha",Strong.easeOut,0,100,0.5,true);  
new Tween(container,"\_alpha",Strong.easeOut,100,50,0.5,true);  
large\_mc.onRelease = function(){  
scrolling = true;  
var myFadeOut = new Tween (large\_mc,"\_alpha",Strong.easeOut, 100,0,0.5,true);  
new Tween(container,"\_alpha",Strong.easeOut,50,100,0.5,true);  
myFadeOut.onMotionFinished=function(){  
for (i=1; i\<=imagesNumber; i++) {  
var myClip = container[“thumb”+i+"\_mc"];  
myClip.enabled = true;  
}  
large\_mc.removeMovieClip();

}  
};  
};  
}  
container.onEnterFrame = function (){  
if (scrolling){  
this.\_x += Math.cos((-\_root.\_xmouse/Stage.width)\*Math.PI)\*15;  
if (this.\_x\>0) {  
this.\_x = 0;  
}  
if (-this.\_x\>(this.\_width-Stage.width)) {  
this.\_x = -(this.\_width-Stage.width);  
}  
}  
};
