A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Slideshow: Slides sticking at certain points.....Bug?

  1. #1
    Senior Member
    Join Date
    Jul 2000
    Posts
    373

    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.

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    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 
    0slides.lengthi++) {
        
    slides[i].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.669;
    rightArrow.161.5;

    var 
    leftArrow:MovieClip = new leftArrow_mc;
    addChild(leftArrow);
    leftArrow.240;
    leftArrow.161.5;

    setChildIndex(rightArrow,numChildren 1);
    setChildIndex(leftArrow,numChildren 1);

    rightArrow.addEventListener(MouseEvent.CLICKslide_right);
    leftArrow.addEventListener(MouseEvent.CLICKslide_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.easeInOutendX, -beginXtweenDurationtrue);
        
        
    // Increment counter
        
    showingIndex++;
        
        
    // If the counter reaches the end of the slides then reset it to 0
        
    if(showingIndex >= slides.lengthshowingIndex 0;
        
        
    // Tween in the next slide
        
    galleryXTweenIn = new Tween(slides[showingIndex], "x"Strong.easeInOutbeginXendXtweenDurationtrue);
    }

    function 
    slide_left(e:MouseEvent):void
    {
        
    // Tween out the active slide
        
    galleryXTweenOut = new Tween(slides[showingIndex], "x"Strong.easeInOutendXbeginXtweenDurationtrue);
        
        
    // Subtract counter
        
    showingIndex--;
        
        
    // If the counter reaches the end of the slides then reset it to length of the array
        
    if(showingIndex 0showingIndex slides.length-1;
        
        
    // Tween in the next slide
        
    galleryXTweenIn = new Tween(slides[showingIndex], "x"Strong.easeInOut, -beginXendXtweenDurationtrue);

    I recommend highly to replace your tweens with TweenLite.

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    373
    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.

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    373
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center