Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Fitchett Developments

Removing Tween and re-adding Tween.

Recommended Posts

Hey guys so im having a little trouble here.

 

So i have a textField that updates after each hitTest which is called levelText. So what im trying to accomplish is the levelText field to fade out after 1 second at the start of each new level. It works fine for the first level but when i go to level 2 or 3 the text field doesnt appear at all. I believe i have to destroy it and re add somehow? Here is the code im using.

 

private function startNextLevel():void
{

 

     TweenLite.to(levelText, 1, {autoAlpha:0});

 

}

 

 

Please any information would help. Thank you.

Link to comment
Share on other sites

Hi

 

If you are using the same text field for each level it sounds like you just need to set its autoAlpha back to 1 before you tween to 0.

 

levelText.visible=true;

levelText.alpha=1;

 

Or use set()

 

TweenLite.set(levelText, {autoAlpha:1});

 

Or use a tween

TweenLite.to(levelText, 1, {autoAlpha:1});

 

Or use a fromTo() tween.

 

TweenLite.fromTo(levelText, 1, {autoAlpha:1},{autoAlpha:0});

Link to comment
Share on other sites

Interesting. Yeah i figured it out last night by setting it to 0 then 1 in the next function. But im confused what does set(); or fromto(); do?

Link to comment
Share on other sites

set() is just a shortcut for a tween with a 0-second duration. It happens instantly.

 

A fromTo() tween allows you to specify the starting (from) and end (to) values of the tween.

 

For instance you could have an mc at x:0. Perhaps when someone clicks a button that mc should jump and tween from x:100 to x:200

TweenLite.fromTo(mc, 1, {x:100}, {x:200});
http://api.greensock.com/as/com/greensock/TweenLite.html
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.
×