Jump to content
Search Community

[SOLVED] TweenMax.allto -> currentProgress/totalProgress Problem

Lasercode test
Moderator Tag

Recommended Posts

Hi folks,

 

I am not really new to this, but I get a hard time trying to do the following:

 

I got an array of MCs named "stepArray". I want to animate through it after a dice function which gives me a number between 1 and 6 (if 5, the stepArray will have 5 elements and so on). Whatever, I need to know when the last element of the array has finished tweening, because that is the time the dice can be used again and is set free. If you need more input, please reply.

 

function animatePlayerMove ():void {
 tweenScaleUp();
}
function tweenScaleUp():void {
 TweenMax.allTo(stepArray, tweenSpeed, {alpha:1, scaleX:1.5, scaleY:1.5, dropShadowFilter:{blurX:15, blurY:15, distance:5, alpha:0.33}, ease:Cubic.easeInOut, onComplete:tweenScaleDown}, stepStaggerAmount);
}
function tweenScaleDown():void {
 tma = TweenMax.allTo(stepArray, 0.2, {alpha:1, scaleX:1, scaleY:1, dropShadowFilter:{blurX:5, blurY:5, distance:5, alpha:0.33}, ease:Cubic.easeInOut}, stepStaggerAmount);
 addEventListener(Event.ENTER_FRAME, checkStepAnimationprogress);
}
function checkStepAnimationprogress (e:Event):void {
 if(tma[tma.length-1].currentProgress == 1){ //This doesnt work properly even with totalProgress
	 trace("STEP ANIMATION ENDS HERE");
	 removeEventListener(Event.ENTER_FRAME, checkStepAnimationprogress);
	 activateDice();
 }
}

 

Obviously there is some mistake in my logics and I hope someone here will help.

 

TIA,

Lasercode

Link to comment
Share on other sites

Hello lasercode

 

Why don't you try to use onComleteAll instead of onComplete:

 

 

function tweenScaleUp():void {
 TweenMax.allTo(stepArray, tweenSpeed, {alpha:1, scaleX:1.5, scaleY:1.5, dropShadowFilter:{blurX:15, blurY:15, distance:5, alpha:0.33}, ease:Cubic.easeInOut, onCompleteAll:tweenScaleDown}, stepStaggerAmount);
}

Link to comment
Share on other sites

For the record, the onCompleteAll is a parameter now, not a special property. It's a cleaner solution because remember, the vars object is passed to each tween that gets created, so individually it wouldn't make as much sense to have an "onCompleteAll" in there. It's method-specific. And allTo() has been renamed staggerTo() in v12 (although there's an undocumented alias that makes allTo() still work for backward compatibility). So in v12, it'd be:

 

TweenMax.staggerTo(stepArray, tweenSpeed, {alpha:1, scaleX:1.5, scaleY:1.5, dropShadowFilter:{blurX:15, blurY:15, distance:5, alpha:0.33}, ease:Cubic.easeInOut}, stepStaggerAmount, tweenScaleDown);

 

Learn more about v12 at http://www.greensock.com/v12/

  • Like 1
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...