Jump to content
Search Community

Part of tween sequence not showing in multiple launch

lastnerve test
Moderator Tag

Recommended Posts

Hi all,

 

I'm new to AS3 but I've managed to get a small tween study working anyway. The code below is a simplified version of what I'm trying to do.

 

The start button launches a series of 4 tweens each time it's clicked and there's no limit on the number of clicks. The tweens handle 3 different "circle" movieclips, each with a different size and color.

 

The "flasher" tween in the code below allows the "circleRed_mc" (which has a duration of only .1) to show with each click, however in the more complex code that I'm trying to fix the "circleRed_mc" doesn't show if the button is clicked rapidly, even though the other 3 display.

 

Do I need to add more copies of the circle objects to avoid the interference between the tweens, or do I need additional tweening functions, or both?

 

A hopefully easier question is why does the last tween ("fadeCircle") not fade out to alpha:0?

 

Here's the code:

 

Frame 1:

 

import gs.TweenLite;
import gs.easing.*;
import flash.display.MovieClip;

var xcoord:Number = 200;
var ycoord:Number = 400;

var circleSmall_mc:circleSmall = new circleSmall();
addChild(circleSmall_mc);
circleSmall_mc.y = ycoord;
circleSmall_mc.alpha = 0;

var circleRed_mc:circleRed = new circleRed(); 
addChild(circleRed_mc);
circleRed_mc.y = ycoord;
circleRed_mc.scaleX = 0; 
circleRed_mc.scaleY = 0;
circleRed_mc.alpha = 100;

var circleLarge_mc:circleLarge = new circleLarge(); 
addChild(circleLarge_mc);
circleLarge_mc.y = ycoord;
circleLarge_mc.scaleX = 0;
circleLarge_mc.scaleY = 0;

stop();

function startMovie(event:MouseEvent):void 
{
   this.play();
}
playButton.addEventListener(MouseEvent.CLICK, startMovie);

 

Frame 2:

 

function leader(large_mc:MovieClip,small_mc:MovieClip,red_mc:MovieClip,xcd1:Number):void {
small_mc.x = 575;
small_mc.y = 700;
small_mc.alpha = 100;
TweenLite.to(small_mc, .5, 
	{x:xcd1, y:ycoord, ease:Strong.easeOut, overwrite:0, 
	onComplete: flasher, 
	onCompleteParams: [large_mc,small_mc,red_mc,xcd1]});
}
function flasher(large_mc:MovieClip,small_mc:MovieClip,red_mc:MovieClip,xcd2:Number):void {
small_mc.alpha = 0;
red_mc.x = xcd2;
TweenLite.to(red_mc, .1, 
	{scaleX:50, scaleY:50, alpha:0,	ease:Strong.easeOut, overwrite:0,
	onComplete: showCircle, 
	onCompleteParams: [large_mc,small_mc,red_mc,xcd2]});
}
function showCircle(large_mc:MovieClip,small_mc:MovieClip,red_mc:MovieClip,xcd3:Number):void {
red_mc.scaleX = 0; 
red_mc.scaleY = 0;
red_mc.alpha = 100;

large_mc.x = xcd3;
large_mc.scaleX = 0;
large_mc.scaleY = 0;
large_mc.alpha = 100;
TweenLite.to(large_mc, 1, 
	{scaleX:1, scaleY:1, ease:Strong.easeOut, overwrite:0, 
	onComplete: fadeCircle, 
	onCompleteParams: [large_mc,small_mc,red_mc,xcd3]});
}
function fadeCircle(large_mc:MovieClip,small_mc:MovieClip,red_mc:MovieClip,xcd4:Number):void {
xcoord = setx(xcd4);
TweenLite.to(large_mc, 1, 
	{alpha:0, ease:Cubic.easeInOut, overwrite:0});
}

function setx(xcd:Number):Number{
if (xcd < 800){
	xcd += 200;
} else {
	xcd = 200;
}
return xcd;
}

leader(circleLarge_mc,circleSmall_mc,circleRed_mc,xcoord);

Link to comment
Share on other sites

Have you read up on your options for overwriting modes? http://blog.greensock.com/overwritemanager/. Why are you setting overwrite to 0? Doing so allows the tweens to conflict with each other (multiple tweens trying to control the same property of the same object). You might want to try the AUTO mode.

 

I don't have time to read through your code right now to troubleshoot, but let me know if the overwriting mode solves the problem.

Link to comment
Share on other sites

Hi, thanks for the help.

Yes, I read some on overwriting, and tried overwrite:0 and overwrite:2, but the results appear to be the same.

 

multiple tweens trying to control the same property of the same object

 

I think this is the problem. A user can click the start button several times per second and the tweens aren't able to keep up with that pace on the same object/same property.

 

I think I need to create an array of objects, each of which can be tweened separately (hopefully with the same series of tweens).

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