# Stopping the slideshow!

**URL:** https://forum.kirupa.com/t/stopping-the-slideshow/116346
**Category:** Uncategorized
**Created:** [July 16, 2004, 7:28pm UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346 "2004-07-16T19:28:20Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![snaphappy](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@snaphappy](https://forum.kirupa.com/u/snaphappy)
#### Post date: [July 16, 2004, 7:28pm UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/1 "2004-07-16T19:28:20Z")

</div>

I’ve tried looking round these forums but can’t seem to find exactly what I need (or perhaps not totally understand the answers). I have set up a slideshow from code on the excellent resizing picture gallery post:

I essentially have this:

```auto
 
function slideshow(){ 
		 if (cur == 0) {
				 containerMC.loadPic(_root.scrll.image_array.length-1);
		 } else {
				 containerMC.loadPic(cur+1);
			
   }
 }; 

start.onRelease = function () {
var slideInterval = setInterval(slideshow, 4000);
 }
  
 stop.onRelease = function () {
 clearInterval(slideInterval);
 }

```

It starts just fine, but I can’t get it to stop.

However, if the line

```auto
var slideInterval = setInterval(slideshow, 4000);

```

is outside the onRelease function then it autostarts (which I don’t want) and then the stop button works.

Can I avoid the autostart, and have buttons which will start AND stop the show?

Any help gratefully received

---

<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 23, 2004, 1:52pm UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/2 "2004-07-23T13:52:52Z")

</div>

Hey Scotty,

the photo site is getting close (or at least closer), but I have another question which is driving me slowly round the bend and can’t seem to figure it out.

I am trying to load the first image in an array when I click a section button, i.e when you click on button one the first set of images loads AND the first image in that set loads in containerMC.

I have this code:

```auto
b1.onRelease = function() {
_root.sectionTitle.text = "Australia";
_root.dragwindow.scrll.select(0);
_root.cur = 0;
_root.containerMC.loadPic(_root.image_array.cur);
 
 
};

```

when I click the button it is showing that cur = 0, and when I click the ‘next’ button it is loading 1, which is fine BUT for the 0 I am getting ‘undefined’ and nothing is loading in the containerMC.

Any clues on how I make this work?

many thanks as always

---

<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 24, 2004, 1:16am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/3 "2004-07-24T01:16:31Z")

</div>

Ok… added the code

```auto
_root.containerMC.loadpic(0);

```

to the bottom of the xml load section in the ‘scroll’ movie:

```auto
 
gallery_xml.onLoad = function(success) {
  if (success) {
   
   var gallery = this.firstChild;
   _root.thumb_array = new Array();
   _root.image_array = new Array();
   _root.title_array = new Array();
   _root.filename_array = new Array();
   for (j=0; j<gallery.childNodes[q].childNodes.length; j++) {
	_root.image_array[j] = gallery.childNodes[q].childNodes[j].attributes.source;
	_root.thumb_array[j] = gallery.childNodes[q].childNodes[j].attributes.thumbsrc;
	_root.title_array[j] = gallery.childNodes[q].childNodes[j].attributes.title;
	_root.filename_array[j] = gallery.childNodes[q].childNodes[j].attributes.filename;
	//trace(thumb_array);trace(image_array);trace(title_array); trace(filename_array);
   
   }
   
_root.containerMC.loadpic(0); // HERE
 
  }

```

and it loads the first picture of each array when you click on a section just fine, but now the resizing function isn’t being triggered - so near and yet…

---

<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 24, 2004, 6:20am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/4 "2004-07-24T06:20:38Z")

</div>

It takes a tiny litlle time for the array’s to get defined, try this:

```auto
gallery_xml.onLoad = function(success) {
	if (success) {
		var gallery = this.firstChild;
		_root.thumb_array = new Array();
		_root.image_array = new Array();
		_root.title_array = new Array();
		_root.filename_array = new Array();
		for (j=0; j<gallery.childNodes[q].childNodes.length; j++) {
			_root.image_array[j] = gallery.childNodes[q].childNodes[j].attributes.source;
			_root.thumb_array[j] = gallery.childNodes[q].childNodes[j].attributes.thumbsrc;
			_root.title_array[j] = gallery.childNodes[q].childNodes[j].attributes.title;
			_root.filename_array[j] = gallery.childNodes[q].childNodes[j].attributes.filename;
		}
		delay = setInterval(showFirst, 50);
	}
};
function showFirst() {
	clearInterval(delay);
	_root.containerMC.loadpic(0);
}

```

scotty(-:

---

<div class="post-metadata">

### Author: ![snaphappy](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@snaphappy](https://forum.kirupa.com/u/snaphappy)
#### Post date: [July 25, 2004, 2:35am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/5 "2004-07-25T02:35:10Z")

</div>

hey Scotty,

thanks for the reply. It looks good and I would never have thought of writing a function to cause the necessary delay! The only problem it seems is that when you go to say section 1 then section 2 then section 1 again the resize doesn’t happen (when you go back to section 1). Sorry to keep asking you slideshow questions and thanks again for the help, I’ll keep trying…

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [July 25, 2004, 7:58am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/6 "2004-07-25T07:58:34Z")

</div>

Weird, can you post your fla?

scotty(-:

---

<div class="post-metadata">

### Author: ![snaphappy](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@snaphappy](https://forum.kirupa.com/u/snaphappy)
#### Post date: [July 25, 2004, 6:16pm UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/7 "2004-07-25T18:16:37Z")

</div>

> [@scotty](#):
>
> Weird, can you post your fla?
> 
> scotty(-:

Hey Scotty,

got it now…I was working with a stripped down version of the fla on another pc last night and I tried the code again on this pc with the full fla and it works perfectly.

Can’t understand why it didn’t work on the other version, must be an error elsewhere in that code, but I guess that version is obsolete now anyway. Thanks a lot Scotty, again a beautiful solution and one I would never have thought of.

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [July 25, 2004, 7:42pm UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/8 "2004-07-25T19:42:36Z")

</div>

welcome=)

---

<div class="post-metadata">

### Author: ![snaphappy](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@snaphappy](https://forum.kirupa.com/u/snaphappy)
#### Post date: [July 27, 2004, 1:35am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/9 "2004-07-27T01:35:32Z")

</div>

hey Scotty, one more solution, one more problem…I’m now trying to load a .swf file into containerMC as an intro before any pics are loaded. I swear I’m nearly through bugging you with photo viewer questions:)

I have tried

```auto
_root.containerMC.loadPic(welcome.swf);

```

but think that the loadPic can only use array values. I tried loadMovie but that didn’t seem to work either.

Do I need to set up an array in the xml file to contain the name of the .swf and then load it from there? I’ve checked out similar posts so know it can be done but can’t seem to get any of the solutions to work. Any clues would be greatly appreciated, thanks!

I’ve posted the [.fla here](http://neelam.port5.com/dd/viewer.fla) as it was too big to upload on the forums

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [July 27, 2004, 7:43am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/10 "2004-07-27T07:43:26Z")

</div>

Have you tried

```auto
_root.containerMC.loadMovie("welome.swf");

```

[size=1]Watch the quotes;)[/size]

scotty(-:

---

<div class="post-metadata">

### Author: ![snaphappy](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@snaphappy](https://forum.kirupa.com/u/snaphappy)
#### Post date: [July 27, 2004, 2:20pm UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/11 "2004-07-27T14:20:37Z")

</div>

Hey Scotty,

thanks for the reply. Going back through some of the other versions on the main viewer thread I found that snippet of code. I tried it and the movie does load.

However the containerMC does not resize and the welcome.swf appears down and to the right of it…any other thoughts?

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [July 27, 2004, 8:23pm UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/12 "2004-07-27T20:23:19Z")

</div>

In your swf make a transparent background with the size of your stage, that should do the trick:)

scotty(-:

---

<div class="post-metadata">

### Author: ![snaphappy](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@snaphappy](https://forum.kirupa.com/u/snaphappy)
#### Post date: [July 28, 2004, 12:13am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/13 "2004-07-28T00:13:10Z")

</div>

> [@scotty](#):
>
> In your swf make a transparent background with the size of your stage, that should do the trick:)
> 
> scotty(-:

quotes are in and the background is set but still no joy:(

if you have any other ideas I would be interested in hearing them. I have linked to the .flas in case you get a chance to look at them

[viewer\_bright.fla](http://neelam.port5.com/dd/viewer_bright.fla)  
[welcome.fla](http://neelam.port5.com/dd/welcome.fla)

thanks for your continuing assistance:)

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [July 28, 2004, 6:14am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/14 "2004-07-28T06:14:31Z")

</div>

I see the problem:)  
In welcome swf, embed your fonts.  
in the viewer\_bright add some coding

```auto
MovieClip.prototype.loadPic = function(pic) {
	if (pic == 9999) {
		containerMC._alpha = 0;
		this.loadMovie("welcome.swf");
	} else {
		containerMC._alpha = 0;
		cur = pic;
		trace(cur);
		this.loadMovie(image_array[pic]+".jpg");
	}
	this._parent.onEnterFrame = function() {
		//rest of your code

```

And to call the swf

```auto
_root.containerMC.loadPic(9999);

```

As you will see, you have to repostion the text in welcome.swf;)

scotty(-:

---

<div class="post-metadata">

### Author: ![snaphappy](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@snaphappy](https://forum.kirupa.com/u/snaphappy)
#### Post date: [July 28, 2004, 9:05am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/15 "2004-07-28T09:05:28Z")

</div>

Hey Scotty,

that looks like a top workaround, I never expected it to be so complicated! The whole idea of writing your own solution through a function is so great and I can now see the logic behind it after working with your other code. Thanks for sticking with it for me, it’s been very beneficial to see the kind of solutions you come up with for these problems; with every one of your posts I learn something new! Going to try it out now…

p.s. Did you see this nice addition to the original thread by Sipher?

- post #376 (!)  
[http://www.kirupaforum.com/forums/showthread.php?t=51430&page=26&pp=15](http://www.kirupaforum.com/forums/showthread.php?t=51430&page=26&pp=15)

---

<div class="post-metadata">

### Author: ![snaphappy](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@snaphappy](https://forum.kirupa.com/u/snaphappy)
#### Post date: [July 28, 2004, 9:39am UTC](https://forum.kirupa.com/t/stopping-the-slideshow/116346/16 "2004-07-28T09:39:24Z")

</div>

its alive…ALIIIIIVE!:te:
