Skip navigation
Currently Being Moderated

Replace Tweener?

May 25, 2012 10:59 AM

Hi all:

After a couple years of not working w/Flash, I'm starting a new project and I see that Tweener is no longer supported.  I've found TweenLite/TweenMax.  Is that a good alternative or are there other recommendations?

Thanks.

 
Replies
  • Currently Being Moderated
    May 25, 2012 2:21 PM   in reply to voxL

    Hi,

     

    Yes, that is one of the best alternatives, the syntax is also similar to Tweener. But, you will barely notice any difference in performance while using basic tweens (TweenLite/Max will most probably perform better in 'extreme' tweening). You may also need to buy a license depending on the project but you can use it for free in commercial one-time fee projects. Even though Tweener is no longer updated, I would say you cannot go wrong using it but there are newer tween engines (TweenLite, BetweenAS3...) so I think we should use those

     
    |
    Mark as:
  • Currently Being Moderated
    May 29, 2012 6:30 PM   in reply to voxL

    On devices use TweenLite. There's been almost absolutely no reason II could ever find to go beyond it. Greensock is your friend. Use it. Appreciate it. I used it in hundreds of projects.

     
    |
    Mark as:
  • Currently Being Moderated
    May 29, 2012 7:27 PM   in reply to voxL

    Ask a more specific question and I can easily tell you how to do it with my favorite, TweenLite.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 6, 2012 10:43 AM   in reply to voxL

    Here's the thing about Flash and your end users system. When you try to set up animation sequences by a certain duration of time, the clients computer may not be fast enough to be ready when that duration comes around. I always daisy chain my animations based on events.

     

    Here's a quick TweenLite example of an animation happening and then triggering another function once it is complete (handling your need for differences in page animation durations):

     

    import com.greensock.TweenLite;

    import com.greensock.easing.Quad;

     

    // create a rectangle shape

    var c:Sprite = new Sprite();

    c.graphics.beginFill(0xFF0000,1);

    c.graphics.drawRect(0,0,100,100);

    c.graphics.endFill();

    addChild(c);

     

    // animate the box from position 0,0 to 100,0 (to the right, 100 pixels, over 1 second)

    // the easing is just for fun....

    TweenLite.to(c,1,{x:100,easing:Quad.easeInOut,onComplete:nextAnimation });

     

    function nextAnimation():void

    {

         // this fires off after the box is at 100,0..

         // now move it down to 100,100 (just move it down)

         TweenLite.to(c,1,{y:100,easing:Quad.easeInOut});

    }

     

    What happened there is I made a red square, added it to the stage and then animated it from 0,0 to 100,0.. then by using the onComplete property and specifying a function name it will call that function as soon as the animation was over. Once it is, that function is called and then I move the box from 100,0 to 100,100...

     

    Point of all of this is you can "daisy chain" your animations on their completedness rather than a specific "time". Being your clients machine may be slower than you suspect, things can take longer to render. So let TweenLite use the onComplete event to trigger the next part of the animation. Then you're guaranteed the animation will happen only after the clients machine has completed the current animation, no matter its speed.

     

    That's how I'd approach it.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 7, 2012 8:12 AM   in reply to sinious

    TweenLite.to(c,1,{x:100,easing:Quad.easeInOut,onComplete:nextAnimation });

     

    FYI, it's ease not easing:

     

    TweenLite.to(c,1,{x:100,ease:Quad.easeInOut,onComplete:nextAnimation });

     

    Using easing won't produce any error either, TweenLite will just ignore it.

     

    And, TweenLite/Max is not a 'good' choice - it is hands down the very best tweening platform for AS3, none of the others even come close in terms of features, or performance.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 7, 2012 9:27 AM   in reply to dmeN

    Yep ease is the property.

     

    Daisy chaining is one way to do it but it does make you continuously need to supply the method name. Not really a bad thing but you can also utilize a TweenEvent which will fire off when your animations do various things.

     

    I use it more to make adjustments as a tween is updating (TweenEvent.UPDATE). It has a COMPLETE handler as well. You can keep track of where you are in your animation in many ways and use a single function that gets called any time a tween completes. Then that function is reused over and over and does the proper thing based on what you're doing. Then you centralize all the events into that one function rather than making a bunch of functions to daisy chain. It's just another strategy that can be cleaner for much more complex tween situations.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 7, 2012 7:14 PM   in reply to voxL

    If you need to be able to pause things you can make a public or global variable that you can continually set the current animation to. For example in a frame script:

     

    var currentAnimation:TweenLite;

     

    Then when creating an animation using TweenLite.to() just assign it, e.g.:

     

    currentAnimation = TweenLite.to(c,1,{x:100});

     

    That will assign the TweenLite reference to currentAnimation. Then at any time you can use the methods pause(), play(), resume(), restart().

     

    e.g. when you want to pause:

     

    currentAnimation.pause();

     

    Then whatever is assigned to that TweenLite will pause. When you want to resume just run:

     

    currentAnimation.resume();

     

    Then at the end whatever onComplete function you listed will still fire off.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points