Jump to content
Search Community

as2 slideshow

jvkirkwo test
Moderator Tag

Recommended Posts

Does anyone know of a slideshow tutorial or source code with greensock transitions? I'm looking for a slide transition with timer and prev and next buttons. I've done it with either buttons or timer but getting both to work is starting to wear on me. Here is the code if you can see ways to help, it would be appreciated. As far as I can tell, the timer part works great by itself, but as soon as I click on a button while in mid-transition, I'll get duplicate copies of timers. Does the onComplete perameter fire even if the tween never reaches it's finish? Is there a way to deal with that? Thanks.

 

var waitTime:Number = 1; //the timer between each transition

 

var clipNum:Number = 0; //dont change

var startX:Number = slides_mc.clip_1._x; //for slide positioning

var homeX:Number = slides_mc._x; //stores original slide_mc x position

var curX:Number = slides_mc._x; //stores the current slide_mc x position

var timer:Number;

var tween:TweenMax;

var clipArray:Array = [slides_mc.clip_1,

slides_mc.clip_2,

slides_mc.clip_3,

slides_mc.clip_4,

slides_mc.clip_5,

slides_mc.clip_6];

 

setPosition();

startTimer();

 

//position all slides side by side

function setPosition():Void

{

for (var i:Number = 0; i < clipArray.length; i++)

{

var clip:MovieClip = clipArray;

 

clip._x = (clip._width * i) + startX;

}

}

 

//start and clear timer

function startTimer():Void

{

timer = setInterval(function ()

{

if (clipNum >= clipArray.length - 1)

{

slide1();

}

else

{

slide2();

}

clearInterval(timer);

}, waitTime * 1000);

}

 

function slide1():Void

{

TweenMax.to(slides_mc,.7,{startAt: {blurFilter:{blurX:20}},

blurFilter:{blurX:0},

_x: homeX,

//delay: waitTime,

ease: Quint.easeOut,

overwrite:3,

onComplete: startTimer});

clipNum = 0;

curX = homeX;

trace("clipNum = " + clipNum);

trace("curX = " + curX);

}

 

function slide2():Void

{

TweenMax.to(slides_mc,.7,{startAt: {blurFilter:{blurX:20}},

blurFilter:{blurX:0},

_x: curX - slides_mc.clip_1._width,

//delay: waitTime,

ease: Quint.easeOut,

overwrite:3,

onComplete: startTimer});

clipNum++;

curX = curX - slides_mc.clip_1._width;

trace("clipNum = " + clipNum);

trace("curX = " + curX);

}

 

//nav buttons

btn_next.onRelease = function()

{

clearInterval(timer);

 

curX = curX - slides_mc.clip_1._width;

clipNum++;

trace("clipNum = " + clipNum);

trace("curX = " + curX);

 

TweenMax.to(slides_mc,.7,{startAt: {blurFilter:{blurX:20}},

blurFilter:{blurX:0},

_x: curX,

ease: Quint.easeOut,

ovewrite:3,

onComplete: startTimer });

}

 

btn_prev.onRelease = function()

{

clearInterval(timer);

 

curX = curX + slides_mc.clip_1._width;

clipNum--;

trace("clipNum = " + clipNum);

trace("curX = " + curX);

 

TweenMax.to(slides_mc,.7,{startAt: {blurFilter:{blurX:20}},

blurFilter:{blurX:0},

_x: curX,

ease: Quint.easeOut,

ovewrite:3,

onComplete: startTimer });

}

Link to comment
Share on other sites

Sorry for all the code. This basically what I need to know. As of now, if tween1 is in mid tween and then gets overwritten by tween2, the onComplete perameter for tween1 still still executes even though it didn't reach the end of the tween. Is there a way to prevent the onComplete from executing?

thanks.

Link to comment
Share on other sites

In version 11, that behavior has been changed so that if all the tweening properties of a tween have been overwritten, the entire tween gets killed meaning the onComplete wouldn't fire. I'd highly recommend checking out v11: http://blog.greensock.com/v11beta/. I think you'll particularly enjoy the new sequencing features offered by the brand new TimelineLite and TimelineMax classes.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...