I have an issue in my function and really need your exceptional brain on this.
I need to create a function to stop looking for the next slide and not give me a error message that the asset is not found.
The condition will be created inside the last function below.
Any help will be great.
Thanks in advance.
These are the functions:
var pictureIndex = 1;
var baseUrl = "initialFrames/";
var image_url = undefined;
var timer = setInterval(next, 2500);
var newImage = new Image();
newImage.onload = imageFound;
newImage.onerror = imageNotFound;
function next()
{
image_url = baseUrl + 'frame_' + pictureIndex + '.jpg';
tryLoadImage(image_url);
}
function tryLoadImage(url) {
newImage.src=url;
}
function imageFound() {
document.getElementById("backInit").src = image_url;
pictureIndex++;
}
function imageNotFound() {
// perform some function to stop calling next()
clearInterval(timer);
}