Jump to content
Search Community

Strange behaviour during a function call

danissimo test
Moderator Tag

Recommended Posts

I have a timeline with infinite repeat and a function call. There are couple of Tweens in that function. It seems these tweens don't fire during the first cycle but do fire in the next cycles. When I delete the repeat option timeline works as expected. Do I miss something?  GSAP 12.1.0 rc2.

Here's the code:

var portraitsTimeline:TimelineMax =  new TimelineMax ({delay:1, repeat:-1, repeatDelay:1});

portraitsTimeline.set (overlay, {visible:false})
		 .call (switchPortraits);

function switchPortraits():void {
	if (!picBox_2.visible){
		picBox_2.visible = true;
	}

	if (currentPortraitNumber < 5){
		currentPortraitNumber++;
	} else {
		currentPortraitNumber = 1;
	}

	if (odd){
		odd = false;
		portraitCurrent = picBox_1;
		portraitNext = picBox_2;
	} else {
		odd = true;
		portraitCurrent = picBox_2;
		portraitNext = picBox_1;
	}

	if (portraitNext.numChildren > 2){
		portraitNext.removeChildAt (2);
	}
		
	var dynamicClassName:String = "Portrait_" + currentPortraitNumber;
	var classReference:Class = getDefinitionByName (dynamicClassName) as Class;
	var currentPortrait:Bitmap = new Bitmap (new classReference (180, 156));

	portraitNext.addChild (currentPortrait);
	portraitNext.getChildAt (2).x = -90;
	portraitNext.getChildAt (2).y = -78;
	
	TweenLite.fromTo (portraitCurrent, 0.7, {x:120, y:115, rotationY:0, scale:1}, {x:-50, y:110, rotationY:50, scale:0.9, ease:Cubic.easeInOut, onStart:function():void {tweenActive = true;}, onComplete:function():void {tweenActive = false;}});
	TweenLite.fromTo (portraitNext, 0.7, {x:290, y:110, rotationY:-50, scale:0.9}, {x:120, y:115, rotationY:0, scale:1, ease:Cubic.easeInOut});
}
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...