# Problem with picture slideshow

**URL:** <https://forum.kirupa.com/t/problem-with-picture-slideshow/330997>\
**Category:** Uncategorized\
**Created:** [April 23, 2013, 5:31pm UTC](https://forum.kirupa.com/t/problem-with-picture-slideshow/330997 "2013-04-23T17:31:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zack\_Bortolotto](https://avatars.discourse-cdn.com/v4/letter/z/f08c70/32.png) [@Zack\_Bortolotto](https://forum.kirupa.com/u/Zack_Bortolotto)\
**Post date:** [April 23, 2013, 5:31pm UTC](https://forum.kirupa.com/t/problem-with-picture-slideshow/330997/1 "2013-04-23T17:31:36Z")

</div>

alright so I am trying to create a picture slideshow on the top of my website… I basically want something like this [http://www.deadmau5.com/](http://www.deadmau5.com/) where the pictures change after 5 sec… and there are buttons to go back and forth… I have almost got it working… The buttons control going back and forth between pictures… but something is messed up with the timmer… it switches 5 seconds just fine but if you press a button to go back or forward it adds additional number of times that it cycles through the pictures… ANY HELP WOULD BE MUCH APPRECIATED…

```auto
import flash.events.MouseEvent;stop();
color_mc1.cacheAsBitmap = true; //color_mc1 is basically the first picture

mask_mc.cacheAsBitmap = true; // is a mask layer that hids part of the pictures
color_mc1.mask = mask_mc;
dotbtn1.addEventListener(MouseEvent.CLICK, boom); // these first 3 buttons let you choose what picture to go to
function boom(event:MouseEvent):void
{
	gotoAndPlay(1);
}
dotbtn2.addEventListener(MouseEvent.CLICK, boom2);
function boom2(event:MouseEvent):void
{
	gotoAndPlay(2);
}

dotbtn3.addEventListener(MouseEvent.CLICK, boom3);
function boom3(event:MouseEvent):void
{
	gotoAndPlay(3);
}

// these two buttons control going forward or back 
btn_3.addEventListener (MouseEvent.CLICK,backward);
btn_4.addEventListener (MouseEvent.CLICK,forward);

	function forward(event: MouseEvent) {
		if(this.currentFrame == this.totalFrames){
			
			gotoAndStop(1);
		}
		else{
			 nextFrame();
		}
												}
												  
												
	function backward(event: MouseEvent) {
		if(this.currentFrame == 1){
			
			gotoAndStop(this.totalFrames);
		}
		else{
			 prevFrame();
			
		}
		
												}
												

// this is the automatic timer that switches frames every 5 sec.
function wait() {
    gotoAndPlay(2); 
	
}stop();
setTimeout(wait, 4500); 

	
												

```
