PDA

View Full Version : TweenLite parameters


ryanhamilton
03-09-2008, 03:10 AM
Using TweenLite AS3; any way to control how much Back or Elastic easing happens. As in making a large movement of 500px and having the amount of Back ease you'd get from say a 100px movement. Same for Elastic.

thanks a ding ding

ryanhamilton
03-09-2008, 05:58 AM
Never mind, I didn't notice someone had asked this same question on the TweenLite site. It was buried in the comments. Here's the answer.


TweenLite doesn’t natively support passing extra parameters to the easing function because doing so would affect performance slightly. TweenLite was carefully tuned to prioritize performance and compactness over trying to be everything to everybody which would lead to “code bloat”. However, there IS a way to do what you’re talking about by simply adding your own easing function that has those parameters hard-coded, like this:

function myCustomEaseOut (t:Number, b:Number, c:Number, d:Number):Number {
var a = 1.5; //Your 1st custom variable
var p = 2.45; //Your 2nd custom variable
if (t==0) return b; if ((t/=d)==1) return b+c;
if (a < Math.abs(c)) {var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
}

TweenLite.to(myMovie2, 1, {y:300, delay:4, ease:myCustomEaseOut, overwrite:false});

Doing it this way may seem a bit more cumbersome, but the code will perform faster, especially when you’re doing vast numbers of simultaneous tweens. It also keeps TweenLite nice and compact which makes me feel all warm and fuzzy inside.

ultraky
03-09-2008, 10:59 PM
groovy

greensock
03-27-2008, 12:28 AM
Actually, I figured out a way to integrate passing extra parameters without hurting performance. The good news is that TweenLite now accepts a special easeParams property which should be an array with all your extra parameters that you'd like to pass the easing equation. So you could do something like:

TweenLite.to(myMovie2, 1, {y:300, delay:4, ease:Back.easeOut, easeParams:[1.5, 2.45], overwrite:false});

Cheers.

ultraky
03-27-2008, 12:34 AM
groovy +1

marfastic
08-25-2008, 07:11 PM
If you would like to make a completely custom tween for use with TweenLite I have created an app for you to do just that http://marfastic.blogspot.com/2008/08/create-custom-tweens-for-tweenlite.html . I based it off of LMC Tween's Flash Panel which allows you to be able to edit a tween to your heart's content.

greensock
08-25-2008, 07:18 PM
If you would like to make a completely custom tween for use with TweenLite I have created an app for you to do just that

Cool! Or try this:
http://blog.greensock.com/customease/

:)

asf8
08-25-2008, 07:36 PM
If you would like to make a completely custom tween for use with TweenLite I have created an app for you to do just that http://marfastic.blogspot.com/2008/08/create-custom-tweens-for-tweenlite.html . I based it off of LMC Tween's Flash Panel which allows you to be able to edit a tween to your heart's content.

Cool! Or try this:
http://blog.greensock.com/customease/

@marfastic, thanks for that.

@greensock, Jack is your tool in anyway optimized further than the ones mentioned below to work more effieciently with your tween classes?

• LacoTween -- Custom Easing Tool
• FuseKit -- customEasingTool2
• Penner Easing Equations -- always an option to just modify for your needs
• Marfastic -- Create Custom Tween's for TweenLite.

I know your big on speed/optimization, but what benefits would one have using yours (donating $) verses using one of the Free ones to create custom tweens? By the way I am not discouraging people from donating, just wishing to know the benefit of your custom ease builder over the others already out there.

Thanks for any feedback! :);)

greensock
08-25-2008, 08:57 PM
Jack is your tool in anyway optimized further than the ones mentioned below to work more effieciently with your tween classes?

Great question. The Penner equations are probably a bit faster than any custom one because there are usually more calculations required with bezier curve values. Frankly, I'm not entirely sure if my CustomEase (http://blog.greensock.com/customease/) is better/faster than the others, but I can tell you that I tried very hard to optimize it for speed, efficiency, and ease-of-use. And I'm not sure if the other tools create equations based on the standard format (where the parameters are time, start value, change in value, and duration) - I suspect they don't. My CustomEase class could be used with virtually any tweening engine becaust it follows the standard format. Again, maybe some of the others do too, but the ones I looked at didn't. I've never tested other ones with TweenLite/TweenMax, but if they don't follow the standard format, they cannot be used (without tweaking at least).

Regarding the donations thing, I just try to find some extra ways to create value for people who support me by joining Club GreenSock (http://blog.greensock.com/club/), and CustomEase is one of my attempts at that. If the other custom ease tools work well for you, by all means, use them instead of mine.

I'd love to hear back as to whether or not the other tools work with TweenLite/TweenMax. I'd try 'em myself, but I'm swamped with work and have a deadline tomorrow :(

Thanks again, Marfastic, for creating a resource for TweenLite/TweenMax users out there!

asf8
08-25-2008, 10:29 PM
Great question. The Penner equations are probably a bit faster than any custom one because there are usually more calculations required with bezier curve values. Frankly, I'm not entirely sure if my CustomEase is better/faster than the others, but I can tell you that I tried very hard to optimize it for speed, efficiency, and ease-of-use. And I'm not sure if the other tools create equations based on the standard format (where the parameters are time, start value, change in value, and duration) - I suspect they don't. My CustomEase class could be used with virtually any tweening engine because it follows the standard format. Again, maybe some of the others do too, but the ones I looked at didn't. I've never tested other ones with TweenLite/TweenMax, but if they don't follow the standard format, they cannot be used (without tweaking at least).

Thanks for the feedback Jack, that is the type of input I was hoping for.

marfastic
08-27-2008, 03:21 PM
Thanks for the support Jack. I am a huge fan of Tweenlite, and would definitely encourage people making donations to the project.

One new feature that I have added that I haven't seen in other packages is the ability to import tween arrays into the Tweening tool. So if you have created a custom tween in the past and want to make modifications to it, you can import the array for that tween and have that tween as a starting point for creating a new tween.