Jump to content
Search Community

getting delays in animation to work

anarchy test
Moderator Tag

Recommended Posts

Hi Again

 

Trying to use the oncompletefunction but not sure if i'm actually doing it right

 

basically i am wanting the object to move then when its finished moving - alpha to 100%

TweenLite.to(_root.btn_work, 2, {_x:328, _y:328, paused:true, onComplete:myFunction, autoAlpha:100, ease:Expo.easeInOut});

 

would appreciate if you could help me cos really just finding my feet with AS2

 

Thanks

Luke

Link to comment
Share on other sites

Hi .. and merry christmas :)

 

First of all - I've never used TweenLite with as2, so bear with me if I'm filling you with nonsense :) I'm sure someone will correct me if I'm wrong.

Second of all - update to as3, you won't regret it :)

I believe this will solve your problem:

TweenLite.to(_root.btn_work, 2, {_x:328, _y:328, ease:Expo.easeInOut});
TweenLite.to(_root.btn_work, 2, {delay:2, autoAlpha:100, ease:Quad.easeIn, onComplete:YourFunctionOne})

function YourFunctionOne() { ... }

//---------------

If your _root.btn_work._alpha is = 0 you could just do like this:
_root.btn_work._x = 328;   _root.btn_work._y = 328;
TweenLite.to(_root.btn_work, 2, {autoAlpha:100, ease:Quad.easeIn, onComplete:YourFunctionTwo, onCompleteParams:["hello"] })

function YourFunctionTwo(s:String) { trace(s); // hello }

 

I hope that made sense :)

Link to comment
Share on other sites

In my opinion, the best way to sequence is to use TimelineLite or TimelineMax because they give you a lot more flexibility compared to just adding delays to your tweens:

 

var myTimeline:TimelineLite = new TimelineLite();
myTimeline.append( TweenLite.to(_root.btn_work, 2, {_x:328, _y:328, ease:Expo.easeInOut}) );
myTimeline.append( TweenLite.to(_root.btn_work, 2, {autoAlpha:100, ease:Expo.easeInOut}) );

 

That way, you can pause(), resume(), reverse(), play() or restart() the whole sequence anytime. Read about TimelineLite at http://blog.greensock.com/timeline-basics/

 

Oh, and if you're using TweenLite, don't forget to activate the AutoAlphaPlugin first:

 

import com.greensock.plugins.*;
TweenPlugin.activate([AutoAlphaPlugin]);

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