Jump to content
Search Community

Trouble reusing my Tweens [SOLVED]

jeremyhoss test
Moderator Tag

Recommended Posts

I have a MovieClip that I want to have the arrow keys call the below functions. When press the right arrow key, I want it to call tweenIntoView() and when press the Left arrow key, I want it to call TweenOutOfView() and I currently have it working fine. The problem is that when I run that tweenOutOfView() function, the MovieClip go's outside of view of the screen and repeatedly calling the method doesn't return it back to where it started. How do I do it properly? The tweenIntoView() function works as I expect because it starts off the screen and zooms into the middle of the screen.

 

//holds the tween to tween in
var tweenInFromLeftSide:TweenMax;

//holds the tween to tween out
var tweenOutFromLeftSide:TweenMax;

public function tweenIntoView() {
tweenInFromLeftSide = TweenMax.from(this, 1, {x:-760, alpha:0, ease:Strong.easeOut});
}
public function tweenOutOfView() {
tweenOutFromLeftSide = TweenMax.to(this, 1, { x:780, alpha:0, ease:Strong.easeOut } );
}

Link to comment
Share on other sites

What's happening in your code is after you've called the tweenOutFromLeftSide function the alpha of "this" is 0.

So when you call tweenInFromLeftSide, calling TweenMax.from won't change the alpha to 1,

because you're already at 0. Think of TweenMax.from as if the tween was just running backwards from it's current value.

In this particular situation, I would either use TweenMax.fromTo, or the startAt property.

 

 TweenMax.fromTo(this, 1, {alpha:0}, { alpha:1, ease:Strong.easeOut});

TweenMax.to(this, 1, { startAt:{alpha:0}, alpha: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...