GTweener has been succeeded by ActuateActuate is way faster, packs more features and has an even cooler API!Check it out!IntroductionCreating tweens is foundational to nearly any project in Flash. While there are always many choices in tweening engines, Tweener has long been an industry standard.
A recent but exciting newcomer is GTween. It is fast, has many features and is making headway in the Flash community.
The Case for CombiningTweener provides excellent "set it and forget it" simplicity. Since it is global, Tweener can automatically stop old tweens that conflict with new ones.
Tweener.addTween (MyClip, { time: 1, alpha: 0 } );
Tweener.addTween (MyClip, { time: 2, alpha: 1 } );However, instance-based engines like GTween require that you maintain context with your old tweens in order to prevent collisions.
var myTween:GTween = new GTween (MyClip, 1, { alpha: 0 } );
myTween.pause ();
var myTween2:GTween = new GTween (MyClip, 2, { alpha: 1 } );GTween includes more features and operates faster than Tweener. That is why I combined the best qualities of both into one library.
Personal tests showed that GTweener adds only a nominal amount of overhead to GTween. Performance using GTweener compared to GTween and other popular libraries, and was nearly three times faster than using Tweener.
Using GTweenerCreating a new tween using GTweener is easy.
GTweener.addTween (MyClip, 1, { alpha: 1 } );The addTween method accepts the same parameters as a new GTween object, and is similar to creating a tween using Tweener.
Pausing, resuming and removing tweens is also simple:
GTweener.pauseTweens (MyClip);
GTweener.resumeTweens (MyClip);
GTweener.removeTweens (MyClip);
GTweener.removeAllTweens ();The addTween, addTweenFilter and addTweenTimeline methods return the actual GTween object which is created, but you can also retrieve these objects later using the getTween or getTweens method:
var alphaTween:GTween = GTweener.getTween (MyClip, "alpha");
var allTweens:Array = GTweener.getTweens (MyClip);Finally, you can also register your own tweens with GTweener. This is useful when you want to create your own tweens by hand, or are using a different kind of tween like GTweenFilter or GTweenTimeline.
var myClipTween:GTween = new GTween (MyClip, 1, { alpha: 1 } );
GTweener.registerTween (myClipTween);Updates(07/03/09) Version 1.2Added new aliases to make GTweener easier to use for developers familiar with Tweener.
rounded will set the snapping property transition will set the ease property transition also supports Tweener string values. "easeOutExpo" will set the ease property to Equations.easeOutExpo (07/01/09) Version 1.1While overwriting previous tweens is usually a great feature, sometimes you still want to add a delay and set up multiple tweens that affect the same property. It is now possible to disable GTweener's overwriting feature to register multiple tweens for the same property. When you do choose to overwrite this property, every one of these previous tweens will be overwritten.
GTweener.addTween (MyClip, 1, { alpha: 1 } );
GTweener.addTween (MyClip, 1, { alpha: 0 }, { delay: 2 }, false);GTweener 1.1 extends the GTween class to provide additional properties to better mirror Tweener. In addition to GTween's initListener, changeListener and completeListener properties, GTweener includes onStart, onStartParams, onUpdate, onUpdateParams, onComplete and onCompleteParams. This is especially useful for reducing code or preventing your listener from being deleted by garbage collection.
GTweener.addTween (MyClip, 1, { alpha: 0 }, { onComplete: removeChild, onCompleteParams: [ MyClip ] );GTweener also includes a new method to make it easy to use tween-based timers.
GTweener.setTimer (10, { onComplete: trace, onCompleteParams: [ "Timer complete" ] } );Finally, setProperties will clear previous tweens and apply properties to your target object instantly. This is similar in functionality to creating a tween with a duration of zero, but zero duration motion tweens have not been supported since GTween Beta 5 was released. Although this is primarily designed for objects you have previously tweened, you can also use the method as a quick way to copy properties from one object to another.
if (animate) {
GTweener.addTween (MyClip, 1, { alpha: 1 } );
} else {
GTweener.setProperties (MyClip, { alpha: 1 } );
}DownloadGTweener includes GTween beta 5 as well as Robert Penner's easing equations, as they are included with Tweener.
There is an example FlashDevelop project available which includes ASDoc documentation for GTweener, or you may download the library by itself.
GTweener Example.zip GTweener.zip FeedbackFeel free to send me an email or write a comment on this forum post if you have any feedback or suggestions.
30 Day Summary Apr 22 2013 — May 22 2013
|
12 Month Summary May 22 2012 — May 22 2013
|
Copyright
©
2013
Black Duck Software, Inc.
and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a
Creative Commons Attribution 3.0 Unported License
. Ohloh
®
and the Ohloh logo are trademarks of
Black Duck Software, Inc.
in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.