Stopping the slideshow!

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:

 
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

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

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:

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

Ok… added the code

_root.containerMC.loadpic(0);

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

 
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…

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

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(-:

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…

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.

welcome=)

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

_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 as it was too big to upload on the forums

Have you tried

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

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

scotty(-:

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?

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
welcome.fla

thanks for your continuing assistance:)

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

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

_root.containerMC.loadPic(9999);

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

scotty(-:

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?

its alive…ALIIIIIVE!:te: