Jump to content
Search Community

AS2 Loop for TweenNano

warmon test
Moderator Tag

Recommended Posts

Hello! I've just started to learn how to work with TweenNano(I'm making banners, so size is extremly important for me) and the main problem was in making animation loop. I found one solution, but may be there are others, more simple?

 

function allanim(){
TweenNano.to(t1, 1, {_y:"-100", onComplete:loopTween});
}

function loopTween():Void {
   allanim();
}
allanim(); 

 

 

PS Sorry for my English, Russian is native, you know...

Link to comment
Share on other sites

I'd say that's probably the cleanest / best approach you are going to find.

 

the only thing that you could do to be .0001% more efficient and would have 0 noticeable benefit is call allanim directly onComplete instead of calling loopTween

 

there aren't a whole lot of methods to work with when using TweenNano.

 

when using your approach, don't you also have to reset all the properties that were tweened back to the normal position?

 

1 thing you could do is

 

have a blank frame on frame 1

have all your assets and code on frame 2

 

stop();
function sequence(){

TweenNano.to(yellow, 1, {x:400});
TweenNano.to(red, 1, {x:200, delay:1, onComplete:gotoAndPlay, onCompleteParams:[1]})
}

sequence();

 

going back to frame 1 will reset all the items back to their starting positions / values.

 

in frame 1 you could have a background color / border / logo or whatever static elements. if you fade everything out before the loop, you won't notice any gap / jump.

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