Slideshow: Slides sticking at certain points.....Bug?
This doesn't happen very often but if you go to http://www.designmg.com/new/portfolio/identity.html and click through the slides you'll notice on occasion, a slide will stick on screen and not slide out. And then the other slides slide under the stuck slide. Obviously, this is not acceptable at all. I tried to upload the .fla but FK keeps giving me a Upload failed error. So I'll just have to include the code below. Hopefully, someone can explain to me why this is happening. Is it possible it's because people are clicking too fast and it's a Flash tweening bug?
--
import fl.transitions.Tween;
import fl.transitions.easing.*;
stop();
stage.frameRate = 31;
var startX:int = 260;
var beginX:int = 801;
var endX:int = 260;
var tweenDuration:int = 1;
var showingIndex:int = 0;
var slides:Array = new Array(new slide1_mc(), new slide2_mc(), new slide3_mc(), new slide4_mc(), new slide5_mc());
for(var i = 0; i < slides.length; i++) {
slides[i].x = startX;
addChild(slides[i]);
startX += slides[i].width;
}
var bkg:MovieClip = new bkg_mc;
addChild(bkg);
var rightArrow:MovieClip = new rightArrow_mc;
addChild(rightArrow);
rightArrow.x = 669;
rightArrow.y = 161.5;
var leftArrow:MovieClip = new leftArrow_mc;
addChild(leftArrow);
leftArrow.x = 240;
leftArrow.y = 161.5;
setChildIndex(rightArrow,numChildren - 1);
setChildIndex(leftArrow,numChildren - 1);
rightArrow.addEventListener(MouseEvent.CLICK, slide_right);
leftArrow.addEventListener(MouseEvent.CLICK, slide_left);
function slide_right(e:MouseEvent):void
{
// Tween out the active slide
var galleryXTweenOut:Tween = new Tween(slides[showingIndex], "x", Strong.easeInOut, endX, -beginX, tweenDuration, true);
// Increment counter
showingIndex++;
// If the counter reaches the end of the slides then reset it to 0
if(showingIndex >= slides.length) showingIndex = 0;
// Tween in the next slide
var galleryXTweenIn:Tween = new Tween(slides[showingIndex], "x", Strong.easeInOut, beginX, endX, tweenDuration, true);
}
function slide_left(e:MouseEvent):void
{
// Tween out the active slide
var galleryXTweenOut:Tween = new Tween(slides[showingIndex], "x", Strong.easeInOut, endX, beginX, tweenDuration, true);
// Subtract counter
showingIndex--;
// If the counter reaches the end of the slides then reset it to length of the array
if(showingIndex < 0) showingIndex = slides.length-1;
// Tween in the next slide
var galleryXTweenIn:Tween = new Tween(slides[showingIndex], "x", Strong.easeInOut, -beginX, endX, tweenDuration, true);
}