Jump to content
Search Community

Ending a Tween

phifunk test
Moderator Tag

Recommended Posts

folks

 

I inherited this code which runs an image carousel in flash cs3. The carousel is at the end of the flash movie but keeps cycling. I just need the tween to stop. here is the code. thanks much

 

import gs.TweenLite;

var CarouselCounter:Number;
var CarouselArray:Array = new Array("Image1","Image2");

CarouselCounter = 0;


NextCarouselImage = function() {
//creates empty holder 
var container:MovieClip = Carousel.createEmptyMovieClip("container", getNextHighestDepth());
container._alpha = 0;
container._xscale = 100;
container._yscale = 100;


//loads
container.attachMovie( CarouselArray[CarouselCounter], "newContainer", getNextHighestDepth());
TweenLite.to(container,  .5,  {_alpha:100, overwrite:false} );
TweenLite.to(container,  .5,  {_alpha:0, delay:4.5, overwrite:false} );


var CarouselInterval = setInterval(Next, 5*1000);

function Next() {
	clearInterval(CarouselInterval);

	if (CarouselCounter >= CarouselArray.length - 1) {
		CarouselCounter = 0
	} else {
		CarouselCounter++;
	}
	NextCarouselImage();
}
}


NextCarouselImage();

Link to comment
Share on other sites

This isn't really a tweening issue, but if you don't want it to keep going to the next one, it looks like you'd probably need to remove this line in your code:

 

var CarouselInterval = setInterval(Next, 5*1000);

 

Or if you want it to go through all the images once, you'd need to restructure your conditional logic and change this:

 

if (CarouselCounter >= CarouselArray.length - 1) {
    CarouselCounter = 0
} else {
    CarouselCounter++;
}
NextCarouselImage();

 

to this:

 

if (CarouselCounter >= CarouselArray.length - 1) {
    CarouselCounter = 0
} else {
    CarouselCounter++;
    NextCarouselImage();
}

 

I'm not positive that's what you need, but hopefully it gives you a nudge in the right direction.

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...