Jump to content
Search Community

Is using TweenLite like this... sanctioned? ::- )

Axonn test
Moderator Tag

Recommended Posts

I got a bit code-lazy the other day and didn't want to complicate myself with Timeline or whatever so I just made a three-step animation like this:

 

Tween.png

 

I attached an image above, because it would be rather hard to format it for the browser. The Forum cuts out the image if you have a small resolution so try opening it in a new tab if that is the case.

 

I wonder if the code above would have any sort of performance woes.

 

Is it a problem that I'm using 3 anonymous functions one in the other? Would I get some sort of garbage collector leaks if I would use that function a lot?

 

I confess that I'm not very up to date with how anonymous functions are tracked & garbage collected in Flash. Maybe somebody can put me straight on that ::- ).

Link to comment
Share on other sites

the same effect could be generated with code that looks similar to:

 

var tl:TimelineLite= new TimelineLite();

tl.append(TweenLite.to(mc, 2, {glowFilter: {color:0xff0000, blurX:10, blurY:10, strength: 3, alpha:1}}));
tl.append(TweenLite.to(mc, 2, {glowFilter: {blurX:0, blurY:0, strength: 5}}));
tl.append(TweenLite.to(mc, 2, {glowFilter: {blurX:50, blurY:50, strength: 5, remove:true}}));

 

I know you admit you were being lazy and all, we've all done it, and you just are curious of the performance issues. I'm not expert in this arena, but here's my 2 cents:

 

Chances are you could "get away" with your method, and I don't necessarily have the knowledge to tell you EXACTLY how garbage collection would handle this or what performance hit you could take.

 

I've been around this forum enough though to trust the experts that strongly recommend against using anonymous functions and chaining them as you have as the potential for future trouble is high.

 

Even if it runs great for you right now, you probably don't want to build further on top of this knowing that there is such potential for things to go wrong when the proper way of doing it (see above) is much more elegant, flexible and reliable.

 

If you can figure out how to manage those three nested onCompletes, I assure you that learning TimelineLite/Max will be a breeze and you will absolutely fall in love with it.

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