GTween V2.01 is a minor update that adds support for AS3 events, allows multiple callbacks at the same position on a timeline, introduces a version property, and fixes a number of bugs reported by users. It also includes a SWC file with the distribution.
Here's the full list of changes:
- added GTween.version property. (thanks to Colin Moock for the request)
- added .dispatchEvents and GTween.defaultDispatchEvents properties, so you can enable AS3 events. (thanks to Colin Moock for the request)
- fixed a problem with tweens in a timeline initing at the wrong time, and added support for position values less than -delay. (thanks to Erik Blankinship for the bug report)
- fixed a problem with tween values being set to NaN before the controlling timeline started playing. (thanks to Erik for the bug report)
- added support for multiple callbacks at a single position to GTweenTimeline. (thanks to sharvey, edzis for the feature request)
- fixed issue with callbacks being called again when a timeline completes. (thanks to edzis for the bug report)
Go to gskinner.com/libraries/gtween to get all the information and download the new release.
I'm planning to migrate the source code to a public repository early in the new year.
Follow @gskinner on Twitter for more news and views on Flash, Flex, and ActionScript.

Comments (26)
"Pause, reverse, and jump to the start or end of the full timeline as easily as you would with a single tween."
This appears to be misleading, because as far as I can tell you can't actually reverse a GTween or a GTweenTimeline. You can set reflect to true, advance to the end of a timeline, and crank repeatCount up, but that's not quite the same thing.
My workaround is to create a GTweenTimeline and set paused to true in all cases. Then, when I want to play or reverse the timeline, I create a GTween that operates on the GTweenTimeline's position property.
TimelineMax handles this case a lot better -- you can just call play() to go forward or reverse() to go backward -- but my client's legal team thinks the greensock corporate licensing terms are too loose and so that library is out of the question. I also like their .append() function for tweens in a timeline -- it's a handy shortcut so that one doesn't have to hand-calculate tween insertion points.
Besides this omission, I'm greatly enjoying your tweening library. It's probably the best-documented and easiest-to-use MIT-licensed tween library out there.
Posted by: Cory Petosky at December 11, 2009 05:09 PMURL: http://petosky.net
Cory - you're right. That description is left from GTween v1, which did have a reverse function and a reversed property. I want to address this at some point to make it easy to work with. For now you can fake it by setting your repeatCount=2, reflect=true, and position=duration, then playing it. This will make it play the reverse portion of the reflect. A bit of a hack, but it should be easier than what you're doing right now.
Posted by: Grant Skinner at December 13, 2009 09:56 PMURL: http://gskinner.com/blog/
Great coding!
Posted by: Posizionamento siti at December 14, 2009 02:58 PMURL: http://www.w3facile.com
hi,
thx for this release,
Posted by: kutu at December 16, 2009 01:44 AMbut i cann't find timingMode in this release.
where it gone?
URL:
"adds support for AS3 events", does that mean youīve added backward compability?! Thatīs more then welcome it thatīs the case. I have not been able to upgrade, since the new version would overwrite the old version and all the old projects using the GTween class would stop work when recompiling.
Anyway, thanks for a great tweening engine! Fast and simple, as it should be :)
Posted by: Patric Jonsson at December 18, 2009 04:36 AMURL: http://www.flashguru.se
I have some issues with GTween when I cast values on the proxy object.
private function handleRedrawAnimationComplete( event : Event ) : void {
event.target.proxy.x = int( event.target.proxy.x );
event.target.proxy.y = int( event.target.proxy.y );
}
This retriggers the whole tween again and again, is that supposed to be?
Posted by: Manuel at December 22, 2009 03:48 AMURL:
Ah yes of course it's supposed to be. My bad, I need to cast on the effective target.
Posted by: Manuel at December 22, 2009 03:53 AMURL:
I have high respect for the work you give to flash community. I actually try to find a fun entry to flash development and gtween discovery : I'd like to create some generative art.
Posted by: Antheor at December 29, 2009 06:18 AMDo you think that as3 + gtween can be ok for generative art ? Are there some samples (art + code) to work on ?
I discovered Context Free and learned its grammar just by 'playing' with existing samples, can I do the same with as3+gtween ?
Thx for any hints.
URL:
Is the reason for dropping event dispatching as the default because of the overhead of creating event objects on performance?
Posted by: Erik at January 2, 2010 12:19 PMURL:
Hi,
I've been playing a little with GTween and proxy:
Works quite nicely, but it seems the onComplete fires 'prematurely' (stop giggling ^^)
example:
var tween:GTween = new GTween( _target, 2 )
tween.ease = Sine.easeInOut;
tween.onComplete = myFunction();
tween.proxy.x -= myValue;
Now, if i trace myFunction(), the onComplete fires
right after start, not after 2 sec. as expected.
Am i missing something?
Btw.:
GTween(_target, 2, {x:myValue}, {ease:Sine.easeInOut, onComplete:myFunction});
works as expected.
Reason for me to use proxy: i want to dynamically add or substract from _targets position - i haven't found how to tween positions relatively, not absolutely. Greensock offers {x:"value"} to move target relatively.
Anyway: cheers for the good work! Many Thx! Martin
Posted by: martin at January 6, 2010 05:22 AMURL:
bug found:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.gskinner.motion::GTween/deleteValue()[/Users/fljot/flash_as3_classes/com/gskinner/motion/GTween.as:565]
at com.gskinner.motion::GTweener$/clearValues()[/Users/fljot/flash_as3_classes/com/gskinner/motion/GTweener.as:193]
at com.gskinner.motion::GTweener$/add()[/Users/fljot/flash_as3_classes/com/gskinner/motion/GTweener.as:109]
at com.gskinner.motion::GTweener$/to()[/Users/fljot/flash_as3_classes/com/gskinner/motion/GTweener.as:89]
Posted by: fljot at January 6, 2010 12:24 PMI have traced, looks like _rangeValues is null. Tweens were with with MotionBlurPluging... Error was appearing from time to time.. useful?
URL:
I discovered a bug in the ColorAdjustPlugin class on line 109 it returns value, but instead I believe it should return NaN. Returning value causes an error on AS3 created Sprites when more than one color adjustment is applied. Ex: Applying both contrast and saturation. This error is caused by a value being returned and it then trying to set that property value and it does not exist.
Switching this line to return NaN fixed this issue in my cases.
Posted by: Devin Reimer at January 12, 2010 12:05 AMURL: http://blog.almostlogical.com
Think I've found a bug (v2.01).
I'm creating some tweens objects ready for setting values later on, but it seems once you instantiate a tween, it begins counting down and then fires the onComplete callback.
For example, I would expect this to make the call on onComplete until after the setValue function is called, but it does:
var assetTween : GTween = new GTween( asset, 0.25 );
Posted by: Tim Cooper at January 12, 2010 04:35 AMassetTween.onComplete = function ( g:GTween ) : void { trace("Logo tweened"); };
URL: http://www.teamcooper.co.uk
hi! i noticed that there's no GTweenFilter in the new version. How do I tween filters then?
Posted by: steph at January 17, 2010 09:44 PMURL:
I guess I am not sure how to use GTween plugins with release 2 for concurrent tweens. It seems that plugins operate on every instance of tween -- do I understand that correctly? Or can I apply different plugins to different concurrent tweens?
Posted by: Erik at February 8, 2010 10:11 PMURL:
Is there a list of all parameters for the color adjust plugin?
contrast works but I get an error with saturation and what are the other properties?
ColorTransformPlugin.install();
Posted by: Chris at February 9, 2010 08:07 PMColorAdjustPlugin.install();
new GTween(renderer, 3, {contrast:-20, blueMultiplier:100}, {repeatCount:0, reflect:true});
URL:
Erik - Plugins are enabled globally. They won't affect a tween unless you are tweening one of their special properties, but you can disable them for a specific tween by changing properties on the tween's pluginData object. For example, to disable the AutoHidePlugin for a tween set:
myTween.pluginData.AutoHideEnabled = false;
You can also change the default enabled state for a plugin by setting it like:
AutoHidePlugin.enabled = false;
See the documentation for each plugin for more information.
Chris - The documentation for the plugin includes all the parameters, though I noticed that it lists "hue" twice instead of saturation. The package also includes a demo of the ColorAdjust plugin in use, including tweening saturation.
Posted by: Grant Skinner at February 9, 2010 08:55 PMURL: http://gskinner.com/blog/
Some of us like to mess with the amplitude and period of the Elastic equations. I added two public vars to GTween: amp:Number = 0; and period:Number = 0;
line 451 of GTween:
ratio = (duration == 0 && _position >= 0) ? 1 : ease(calculatedPosition/duration,0,1,1);
replaced by:
if (duration == 0 && _position >= 0)
{
ratio = 1;
}
else
{
if (amp > 0 || period > 0)
ratio = ease(calculatedPosition/duration, 0, 1, 1, amp, period);
else
ratio = ease(calculatedPosition/duration,0,1,1);
}
The Elastic class has to be altered to accept amp and period as arguments, with default 1 and 0.3. The vars a and p in all equations become amp and period respectively. The 's' becomes var newS:Number = period / 4;
It works. Make it so?
Posted by: Matt at February 15, 2010 10:35 PMURL:
Is there a way to change values relatively? e.g. xBy or yBy?
Posted by: Mateusz at February 16, 2010 04:13 AMURL:
There seems to be a bug in GTween class:
public function deleteValue(name:String):Boolean {
delete(_rangeValues[name]);
delete(_initValues[name]);
return delete(_values[name]);
}
Try example when you have simple fade in/out on some component when mouse over/out
mouse over:
GTweener.add(new GTween(closeButton, 0.5, {alpha: 1});
mouse out:
GTweener.add(new GTween(closeButton, 0.5, {alpha: 0});
than try to move mouse very fast in and out... you'll get an null reference error in the function I pasted above on properties "_rangeValues" and "_initValues". Please try to fix it before the new release! Thanks
If I'm doing it wrong please provide me with a correct use case.
Posted by: Mateusz at February 18, 2010 02:28 AMURL:
I've made some other test and I figured out that the issue is present only when tweeing by using Gtweener. It's ok when using only Gtween instance and not passing it to Gtweener.
Posted by: Mateusz at February 18, 2010 02:34 AMURL:
Luckily I got some time to start having looking at it. I extended the previous version (especially the updateProperty method) so that based on the type of value (ie. ColorTransform, Rectangle, Point, but also other custom VOs) could interpolate the value accordingly.
Based on the new architecture I presume I should create plugins for those interpolations. I'm only concerned that those plugins are static, which means, for instance, that the property which will handle a different VOs should be consistent across the all application. Not very scalable I would say. Other option is to modify the "set position" method.
What is your opinion/recommendation? And about the scalability of this plugin architecture?
Best, chr
Posted by: christian at February 24, 2010 05:55 AMURL: http://nuthinking.com
mmm, also the interpolation start to start+range can be a problem on different property types. start to end is handier :(
Posted by: christian at February 24, 2010 06:13 AMURL: http://nuthinking.com
thanks to the callback feature, we can now consider using your lib in our project. Thanks for that, you rock.
Posted by: sharvey at February 24, 2010 08:33 AMURL:
I've played with gtween and found a kind of bug :
Posted by: Antheor at March 10, 2010 12:47 PMmy tweens are interrupted when meeting other tweens.
example :
I hace a tween launched on mouseover
myTween =new GTween(mySprite,2,{scaleX:3,scaleY:3,alpha:0}{reflect:true,repeatCount:2})
If I mouseover before the end of this tween, mySprite get stuck.
For example with a duration of 2 second and a relaunch at 1s, mySprite is now always at scale 3.
...
I have tried with or without reflect/alpha/repeatCount,... whatever the tween, I have always the same issue (not going back to the initial mySprite). I have also tried resetValues with no success ...
Quite annoying.
- if people have no time here to answer, could you please give a place (forum) where to ask ...:)
URL:
Hi Grant,
I love the work do and am very happy with your GTween class which has already found numerous uses. A bit silly to get back here only to complain though... an earlier thank you would have been nice. Hopefully I can supply the fix as well, so I'm not all bad ;).
I noticed that when using tweens with delays, the delays are ignored after the first time you use the proxy object. Now, I might not get the complete intricacies of your GTween class, but as I see it the problem lies in the 'invalidate' function on line 701:
if (_position > 0) { _position = 0; }
This resets the position to 0 instead of -delay, which is what the delay setter does. Perhaps there is a better place to fix this... but replacing the line with
if (_position > -delay) { _position = -_delay; }
does seem to work like a charm.
Hope this helps, and thanks again,
Posted by: Niels Keetlaer at March 11, 2010 01:34 PMNiels
URL: