Skip to content
Nov 8 2009 / alecmce

Tweening with Tweensy – Properties and Colors

I’ve started using Tweensy after realising that TweenMax requires a license fee for commercial use. Though my personal use is seldom commercial, why learn a library that’s useless to me when I am doing commercial work?

Firstly, a big nod to Shane McCartney, who has done the hard work of creating this new tweening library.

A new library means learning a new syntax. As I go, I will post a few things that I learn along the road, since as yet, Tweensy is not that widespread:

A Simple Tween

To tween an object’s position you can use a static method, like TweenMax:

Tweensy.to(myDisplayObject, {x:300, y:100});

It will tween over half a second, unless you add a third parameter indicating the duration of time. This is very close to TweenMax. The static method produces a TweensyTimeline, or you could just create a new TweensyTimeline and add the various properties to it.

A Color Tween

To tween an object’s color, you can create a TweensyGroup and add a colorTransformTo call to it.

var tween:TweensyGroup = new TweensyGroup();
var color:ColorTransform = new ColorTransform();
color.color = 0xFF0000;
tween.colorTransformTo(myDisplayObject, color);

A TweensyGroup I thought? I bet you can tween more than just one item simultaneously with that. And so you can:

Roll-over to trigger the tweens. Click outside when you’ve had enough! If for some odd reason you want the source then you can download it here.

A bit of API confusion

As yet, I’m not really clear what is the difference between a TweensyGroup and a TweensyTimeline. I’m sure it will become apparent. You can’t call TweensyTimeline.colorTransformTo though TweensyGroup.colorTransformTo returns a TweensyTimeline. My suspicion is that Shane spends longer at the chalk-face of creating his extremely impressive BitmapData effects than he does doing the dull-but-important job of ensuring that his API is clean and tidy. Alternatively, there may be a very good reason for the API decision, in which case I am extremely sorry for that supposition.

  • http://twitter.com/alecmce alecmce

    A quick post on #as3 tweening with #Tweensy: http://bit.ly/O6NdX
    This comment was originally posted on Twitter

  • http://www.jacksondunstan.com/ Jackson Dunstan

    I’ve recently been using TweensyZero instead of Tweensy since my tweening needs are light, it’s really fast, and it’s really small. Have you checked it out? If so, what are your impressions?

  • http://www.jacksondunstan.com Jackson Dunstan

    I’ve recently been using TweensyZero instead of Tweensy since my tweening needs are light, it’s really fast, and it’s really small. Have you checked it out? If so, what are your impressions?

  • http://alecmce.com Anonymous

    Not yet, Jackson. I may look into it in the coming months.

  • http://alecmce.com alec

    Not yet, Jackson. I may look into it in the coming months.

  • http://twitter.com/flashgoblin Shane Hoffa

    TweenMax only requires you to pay if the end user of your application has to pay to view it. Like if there is a membership fee for a site, or an end user is purchasing a CD-Rom what has Flash content on it that uses TweenMax. Other than that, it is free.

    • http://alecmce.com Alec McEachran

      Yes Shane, you’re absolutely right. Here are some problems with that:

      If I write code for the purposes of creating a free piece of software, then want to reuse my code for a commercial venture, I have to refactor the TweenMax library out of the code.

      If I am a freelancer and then am contracted to work for a big company looking to create a commercial product, my knowledge of TweenMax is useless to me.

      If I create an ‘open-source’ library with dependencies on TweenMax my MIT license is invalid, and though I am no lawyer, I might be liable to pay for the Greensock license on behalf of companies who use my source in commercial projects.

      In my opinion, using TweenMax for non-commercial projects reduces my knowledge of libraries that are truly open-sourced, and runs the risk of violating licenses. Greensock are welcome to their license, but as soon as I learned of it, I removed every reference to their code from my hard-drive. I would urge others to do the same, unless they work for a company who have decided to pay for the code.

  • http://twitter.com/flashgoblin Shane Hoffa

    TweenMax only requires you to pay if the end user of your application has to pay to view it. Like if there is a membership fee for a site, or an end user is purchasing a CD-Rom what has Flash content on it that uses TweenMax. Other than that, it is free.

  • http://alecmce.com alecmce

    Yes Shane, you're absolutely right. Here are some problems with that:

    If I write code for the purposes of creating a free piece of software, then want to reuse my code for a commercial venture, I have to refactor the TweenMax library out of the code.

    If I am a freelancer and then am contracted to work for a big company looking to create a commercial product, my knowledge of TweenMax is useless to me.

    If I create an 'open-source' library with dependencies on TweenMax my MIT license is invalid, and though I am no lawyer, I might be liable to pay for the Greensock license on behalf of companies who use my source in commercial projects.

    In my opinion, using TweenMax for non-commercial projects reduces my knowledge of libraries that are truly open-sourced, and runs the risk of violating licenses. Greensock are welcome to their license, but as soon as I learned of it, I removed every reference to their code from my hard-drive. I would urge others to do the same, unless they work for a company who have decided to pay for the code.

  • http://MastermindCoding.com/ Miller J.

    You do it like this without using the group:

    var NewColor:ColorTransform = new ColorTransform();
    NewColor.color = 0xEEEEEE;
    Tweensy.to(TheObject.transform.colorTransform,NewColor,2.0,null,0,TheObject);

  • http://MastermindCoding.com/ Miller J.

    You do it like this without using the group:

    var NewColor:ColorTransform = new ColorTransform();
    NewColor.color = 0xEEEEEE;
    Tweensy.to(TheObject.transform.colorTransform,NewColor,2.0,null,0,TheObject);

  • Pingback: Tweensy | massiveProCreation Blog