In the quest to find the most flexible, lightweight, and best performing tweening engine for Flash, I have come across a variety of packages including TweenMax/TweenLight, Go/HydroTween, and the new gTween. Currently, I swing towards TweenMax as the benchmarks have been favorable to it when dealing with hundreds of objects simeltanously. This aside though, I have been fascinated with Grant Skinner‘s gTween proxy idea. He creates a proxy object for a movieclip that allows automatic tweening on properties that the user would normally find and operate without a tween engine manually. See the below examples as they will make much more sense than a written explanation in this case.

Grant explains his proxy idea below:

Proxy Tweening

gTween provides a unique proxy property that allows you to work with tween destination values the same way you would work with them on the target object. The proxy object effectively “stands in” for your target object.

This simple example shows how you can use the proxy to move the target object 100 pixels to the right.

myTween.proxy.x += 100;

In the above example, the proxy will retrieve the x value from the target object (if it doesn’t already exist as a destination value in the tween), add 100, and set it back as a destination value for the tween.

This idea seemed very unique yet very straight forward for the person who implements the class. I have decided to write a wrapper class for TweenMax to do the same thing. Below is an example on how the client would use it for making an object tween across the screen, blur, and fade:

import gs.*;
// box is a movieclip ID
var boxTween:TweenMaxProxy = new TweenMaxProxy(box);
boxTween.x+=100;
boxTween.y+=100;
boxTween.blur+=11;
boxTween.alpha-=0.3;

You can find a working copy here of my tween proxy for TweenMax: TweenMaxProxy. You can just drop this file into the /gs/ folder of TweenMax. As of right now, it only supports the properties x, y, alpha, and blur. If people find this helpful though, I can build this out more than it is.

While the syntax is a little bulky compared to the pure object syntax to make a tween with most tweening engines, this method is the only optimal way that I have derived to have a fast way for users to find and utilize tween properties without having to keep pulling docs up.

My TweenMaxProxy Class
TweenMax Link: http://blog.greensock.com/tweenmaxas3/
gTween Docs: http://www.gskinner.com/blog/archives/2008/08/gtween_a_new_tw.html#proxy


Author: Jonathan Dunlap
Jonathan is an experienced software engineer, sole blogger of JADBOX, author of FlashMVC, humanitarian, and has contracted work for Microsoft, Coke, and Disney.
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Furl
  • LinkedIn
  • Pownce
  • Reddit
  • StumbleUpon
  • TwitThis
Auto-Generated Related Posts:
  1. Countdown to Mobile Flash Player 10...

Tags: