Semi-Beginner AS 2 user in need of some help from a GURU
I am creating a flash slideshow that dynamically loads images via XML. The slideshow has thumbnails to select a specific image, a slideshow mode (where it will simply play through the images) and will advance to the next image when you click on the current image in the slideshow.
The problem I'm having is that when I use the thumbnails to select an image (say Image 5 in the list of thumbnails) it will go to that image, but when I resume the slideshow it will not resume from the slide it left off on. It will select the image that it had left off on prior to clicking the thumbnail.
Can someone tell me what I'm doing wrong here...please?
I can't upload the files as an attachment because they are too big...aye aye aye.
CODE HERE:
var xmlPath = "content_fair.xml";
var photos_xml = new XML();
photos_xml.ignoreWhite = true;
var imageList:Array = new Array();
photos_xml.onLoad = function(success) {
if (success) {// ----------- load successful
// ----------- convert XML content to an array
imageList = photos_xml.firstChild.childNodes;
// ----------- Do some action once xml is loaded
loadImage();
// ----------- Do some action once xml is loaded
} else {
// ----------- problem loading, check path
trace("Error loading photos_xml");
}
};
//Load Images//
var currentImage:Number = 0;
var imageLoader:MovieClipLoader = new MovieClipLoader();
var loadListener:Object = new Object();
imageLoader.addListener(loadListener);
loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void {
TweenLite.to(shell_mc.background_mc,0.75,{_width:t arget_mc._width+20, _height:target_mc._height+20, ease:Quad.easeOut});
TweenLite.to(shell_mc.border_mc,0.75,{_width:targe t_mc._width, _height:target_mc._height, ease:Quad.easeOut});
TweenLite.to(shell_mc.mask_mc,0.75,{_width:target_ mc._width, _height:target_mc._height, ease:Quad.easeOut});
// center content
var clipXTarg = Math.round((Stage.width/2)-((target_mc._width)/2));
var clipYTarg = Math.round((Stage.height/2)-((target_mc._height)/2));
TweenLite.to(shell_mc,0.75,{_x:clipXTarg, _y:clipYTarg, ease:Quad.easeOut});
// find previous image
if (currentImage == 0) {
var prevImgNum = imageList.length-1;
} else {
var prevImgNum = currentImage-1;
}
var prevImg = shell_mc.pics_mc["pic"+prevImgNum];
TweenLite.to(prevImg,0.75,{autoAlpha:0, onComplete:removePrevious});
};
loadListener.onLoadComplete = function(target_mc:MovieClip):Void {
TweenLite.to(target_mc,0.75,{autoAlpha:100, delay:0.75});
setTimer();
};
//////////////////////////////////////////////////////////////////
// Functions List
//////////////////////////////////////////////////////////////////
timer = setInterval(loadImage, 3000);
function removePrevious() {
if (prevImg != undefined) {
removeMovieClip(prevImg);
}
// increment the current image
if (currentImage<imageList.length-1) {
currentImage = currentImage+1;
} else {
currentImage = 0;
}
}
function loadImage() {
var loadURL = imageList [currentImage].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
trace(currentImage);
trace(targetClip);
trace(loadURL);
imageLoader.loadClip(loadURL,targetClip);
}
function loadImageResume() {
var loadURL = imageList [currentImage].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
trace(currentImage);
trace(targetClip);
trace(loadURL);
imageLoader.loadClip(loadURL,targetClip);
}
play_but.onPress = function() {
play_but.onRelease = function(){
play_but.gotoAndStop(2);
stop_but.gotoAndStop(1);
clearInterval(timer);
timer = setInterval(loadImageResume, 3000);
}
};
stop_but.onPress = function() {
clearInterval(timer);
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
};
shell_mc.onPress = function(){
loadImage(currentImage +1);
clearInterval(timer);
}
shell_mc.onRelease = function(){
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
}
_root.onLoad= function(){
play_but.gotoAndStop(2);
}
//////////////////////////////Thumb Functions/////////////////////////////////////
function loadImage1() {
var loadURL = imageList[0].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
trace(currentImage);
trace(targetClip);
trace(loadURL);
}
function loadImage2() {
var loadURL = imageList[1].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage3() {
var loadURL = imageList[2].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage4() {
var loadURL = imageList[3].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage5() {
var loadURL = imageList[4].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage6() {
var loadURL = imageList[5].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage7() {
var loadURL = imageList[6].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage8() {
var loadURL = imageList[7].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage9() {
var loadURL = imageList[8].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage10() {
var loadURL = imageList[9].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage11() {
var loadURL = imageList[10].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage12() {
var loadURL = imageList[11].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage13() {
var loadURL = imageList[12].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage14() {
var loadURL = imageList[13].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage15() {
var loadURL = imageList[14].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage16() {
var loadURL = imageList[15].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage17() {
var loadURL = imageList[16].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage18() {
var loadURL = imageList[17].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage19() {
var loadURL = imageList[18].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
function loadImage20() {
var loadURL = imageList[19].attributes.imgurl;
var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+curren tImage, shell_mc.pics_mc.getNextHighestDepth());
targetClip._alpha = 0;
imageLoader.loadClip(loadURL,targetClip);
}
///////////////////////////////Thumb Control/////////////////////////
thumbs.slide_1.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage1();
clearInterval(timer);
};
thumbs.slide_2.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage2();
clearInterval(timer);
};
thumbs.slide_3.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage3();
clearInterval(timer);
};
thumbs.slide_4.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage4();
clearInterval(timer);
};
thumbs.slide_5.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage5();
clearInterval(timer);
};
thumbs.slide_6.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage6();
clearInterval(timer);
};
thumbs.slide_7.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage7();
clearInterval(timer);
};
thumbs.slide_8.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage8();
clearInterval(timer);
};
thumbs.slide_9.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage9();
clearInterval(timer);
};
thumbs.slide_10.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage10();
clearInterval(timer);
};
thumbs.slide_11.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage11();
clearInterval(timer);
};
thumbs.slide_12.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage12();
clearInterval(timer);
};
thumbs.slide_13.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage13();
clearInterval(timer);
};
thumbs.slide_14.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage14();
clearInterval(timer);
};
thumbs.slide_15.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage15();
clearInterval(timer);
};
thumbs.slide_16.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage16();
clearInterval(timer);
};
thumbs.slide_17.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage17();
clearInterval(timer);
};
thumbs.slide_18.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage18();
clearInterval(timer);
};
thumbs.slide_19.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage19();
clearInterval(timer);
};
thumbs.slide_20.onPress = function() {
play_but.gotoAndStop(1);
stop_but.gotoAndStop(2);
loadImage20();
clearInterval(timer);
};