I have a slideshow that swaps images by adding and subtracting by image name on the previous and next click events. Is there anyway to assign 6 different URLS based on the image names to the object mainImage?
var numOfPhotos = 6;
var pic = sym.$("mainImage");
var textCount = sym.$("tbCount");
var imageSource = pic.attr('src');
var imageCount = +(imageSource.slice(13,15));
imageCount = imageCount+1;
if (imageCount>numOfPhotos) {imageCount = 1};
var newCount = imageCount + ' of '+numOfPhotos;
if (imageCount<10) {imageCount = '0'+imageCount};
imageSource = 'images/photo-'+imageCount + '.jpg';
pic.attr('src',imageSource);
textCount.html(newCount);
window.trackEvent('prev');
This image swap is from Edge Animate the Missing Manual Chaper 9
http://dl.e-book-free.com/2013/07/adobe_edge_animate_preview_7_the_missing_manual.pdf
how does Photo Show keep track of the currently displayed photo? It steals that bit of information from the JPEG filename. Remember each photo is named something like photo-03.jpg or photo-05.jpg. The first task is to get the entire photo name:
var imageSource = pic.attr('src');
The new pic variable is used to identify the mainImage. Then, its src attribute is stored in another new variable imageSource. That stores an entire path and filename like images/photo-03.jpg in imageSource as a string. The next line of code slices the number out of the filename.
var imageCount = +(imageSource.slice(13,15));
The value is stored in yet another variable, imageCount