-
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);
}
Last edited by databell; 05-24-2009 at 10:50 AM.
Reason: File won't Upload.....must embed code instead.
Adam Bell
dzign@datatv.com
--
Over 90% of all websites
suck......
Join the minority.
-
Moving your tween variable declarations outside should fix it:
PHP Code:
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);
var galleryXTweenIn:Tween; var galleryXTweenOut:Tween;
function slide_right(e:MouseEvent):void { // Tween out the active slide galleryXTweenOut = 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 galleryXTweenIn = new Tween(slides[showingIndex], "x", Strong.easeInOut, beginX, endX, tweenDuration, true); }
function slide_left(e:MouseEvent):void { // Tween out the active slide galleryXTweenOut = 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 galleryXTweenIn = new Tween(slides[showingIndex], "x", Strong.easeInOut, -beginX, endX, tweenDuration, true); }
I recommend highly to replace your tweens with TweenLite.
-
Seems to work so far. Thanks. I'll repost if any other problems occur.
Adam Bell
dzign@datatv.com
--
Over 90% of all websites
suck......
Join the minority.
-
Well, just tried it again and this time got a stuck slide. You really think it would work better with TweenLite?
Adam Bell
dzign@datatv.com
--
Over 90% of all websites
suck......
Join the minority.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|