Jump to content
GreenSock

danee987

Appending a Tween that was return by a function?

Recommended Posts

Hi I was wondering if this is possible? I have a function that runs a tween i use for many different items but at one point i would like to append this function call to a timlineMax instance so it runs in sequence with other tweens I made. Here is my code:

 



var $timeline:TimelineMax = new TimelineMax();
$timeline.append(TweenMax.to(_container.tile, .5, { x:308, y:235 } ));
$timeline.append(Delegate.create(AnimationPresets.instance.scaleIn, _container.measurements_mc)) // <--- as you can see this tween is created  by a "scaleIn" function


public function scaleIn($d:DisplayObject):TweenMax {

return TweenMax.to( $d, .2, { scaleX:1.4, scaleY:1.4, ease: Linear.easeNone } )
}



 

But the above is not working because I guess it tries to append without executing the method call which would give it a valid TweenMax Tween. Any idea how I could do something like this?

Link to comment
Share on other sites

I believe Delegate returns a Function, while TimelineMax is looking to append an instance of TweenMax.

 

This line:

$timeline.append( Delegate.create( AnimationPresets.instance.scaleIn, _container.measurements_mc ) );

would essentially be:

$timeline.append( AnimationPresets.instance.scaleIn );

I would try the following to append a TweenMax to the timeline:

$timeline.append( AnimationPresets.instance.scaleIn( _container.measurements_mc ) );

Link to comment
Share on other sites

This worked perfectly. I thought I needed to use Delegate there to keep my method from calling right away. Didn't think of trying it without it:) Thanks!

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