Next Generation Emulation banner

1 - 6 of 6 Posts

·
The Upcoming Rookie
Joined
·
620 Posts
Discussion Starter #1
I was thinking was it possible to make a for loop with this piece of javascripot code? This is a slidshow script. I want it to make the variable "thisPic" to loop, as long as their as is an image or set of images to slideshow.

Code:
var thisPic = [0, 0, 0, 0, 0];
function chgSlide(change, direction)
	{
	if(document.images)
		{
		thisPic[change] += direction;
		imgCt = (imageChoice[change].length -1 && altChoice[change].length -1);
		if(thisPic[change] > imgCt)
			thisPic[change] = 0;
		if(thisPic[change] < 0)
			thisPic[change] = imgCt;
		document.getElementById(slideID[change]).src = imageChoice[change][thisPic[change]];
		document.getElementById(slideID[change]).alt = altChoice[change][thisPic[change]];
		}
	}
 

·
Premium Member
Joined
·
26,303 Posts
You should be able to find out how large the array is once filled. You then just do something like
if change >= maxchange then change = 0
 

·
The Upcoming Rookie
Joined
·
620 Posts
Discussion Starter #3
Kane-Sama said:
You should be able to find out how large the array is once filled. You then just do something like
if change >= maxchange then change = 0
Yeah, I have been trying to do that, but the thing keeps freezing... :cuss2:
 

·
Banned
Joined
·
177 Posts
This may be alittle off topic but not so long ago a few buddies and I did some research and found that in .net arrays dont allocate all the memory until each instance in the array is used...in other words myarray(10000) if you call up the first 5k only the first 5k will be tossed in memory. I can see good and bad things about this approach.
 

·
Premium Member
Joined
·
26,303 Posts
How about
if thisPic[change] = null then change = 0
 

·
The Upcoming Rookie
Joined
·
620 Posts
Discussion Starter #6 (Edited)
Kane-Sama said:
How about
if thisPic[change] = null then change = 0
Close but still kinda of screwy. Still not working right.

The thing is, though, I don't want to know how long the array is; I want the javascript to figure that out. Just a note.

And oh yeah, what do ou exactly mean by maxchange?
 
1 - 6 of 6 Posts
Top