|
TweensyOriginal
TweensyThe Tweensy class contains static methods (for coding convenience) to create and control tween animations. Below are some simple steps to help you get started with creating your first animations with Tweensy. Documentation for Tweensy can be found under the folder 'documentation/original' or online Doing a tweenAnimations can be done using one of the following methods : A 'to' tweenIs an animation which goes from the instances current position to the destination defined in the 'to' Object. import com.flashdynamix.motion.Tweensy; This will animate 'myInstance' from it's current x to the x position of 500. A 'from' tweenIs essentially the opposite of a to based tween. It is an animation which goes from the destination defined in the 'from' Object to the instances current position. import com.flashdynamix.motion.Tweensy; This will animate 'myInstance' from the x position 500 to it's current x position. A 'fromTo' tweenIs using both the features of a from and to tween. It is an animation which goes from the destination defined in the 'from' Object and to the destination defined in the 'to' Object. import com.flashdynamix.motion.Tweensy; This will animate 'myInstance' from the x position of 0 to the x position of 500. Controlling tweensTweensy provides methods which allow for the controlling of tweens whilst they are in animation. Stopping a tweenAllows for stopping a tween in motion via an Object instance or property names. import com.flashdynamix.motion.Tweensy;
Tweensy.to(myInstance1, {x:500, y:500});
Tweensy.to(myInstance2, {x:500, y:500});
Stops all tweens for myInstance1 though tweens will continue for myInstance2. Tweensy.stop(myInstance1, "x"); Stops tweens for the x property for myInstance1. Tweensy.stop(null, "x"); Stops all tweens for the x property animating in Tweensy. Tweensy.stop(myInstance2); Stops all tweens for myInstance1 and myInstance2. Tweensy.stop(myInstance2, "x"); Stops tweens for the x property for myInstance1 and myInstance2. Pausing and resuming a tweenAllows for pausing and resuming all tweens executed by Tweensy. Tweensy.pause(); Tweensy.resume(); Time based vs Frame basedBy default Tweensy uses time based animations, this ensures that tweens end precisely in the time you define. Movieclip animations created in the Flash IDE are frame based and Tweensy offers an option to use this mode also. When using frame based animations you can define how many seconds per frame are applied on each ENTER_FRAME. So if you wanted to match the FLA frame rate of 30FPS the SPF would be 1/30. Or if you wanted to double the frame rate this would be (1/30) multiplied by 2. Tweensy.refreshType = Tweensy.FRAME; Tweensy.secondsPerFrame = 1/30; Updating a tween in motionTweens in motion can have there positions seamlessly updated within the animation time remaining. Tweensy.updateTo(myInstance, {x:250}); Repeating tweensTweens can be set to be repeating with the following types yoyo, loop and replay in either an endless or for a finite loop count.More information regarding repeating animations can be found in the documentation. import com.flashdynamix.motion.; This will animate 'myInstance' from its current x position to an x position of 500 to and fro 3 times. Other things to know about tweensWhen a to, from or fromTo tween is defined it returns an instance of TweensyTimeline this contains the parameters of this tween which you may modify during the tweens animation. Using timelinesWhen a to, from or fromTo tween is defined it will return an instance of TweensyTImeline. Using TweensyTImeline allows for defining parameters which are not in the to, from and fromTo method as well as updating properties during the tweens animation. import com.flashdynamix.motion.; This will animate 'myInstance' from it's current x to the x position of 500 in 3.5 seconds rather than the initially defined 2 seconds. Timelines offer a lot more functionality which will be described in further detail below. Relative and random range positionsThe properties in the to and from Objects allow for you to define a relative position or random range positions. Using ease equationsEase equations change the style of movement from point A to point B. Tweensy supports all the ease equations provided via Adobe in the fl.motion.easing package and these have been provided as a part of the Tweensy library. By default Tweensy will use the ease equation Quintic.easeOut if null or no parameter is provided. import com.flashdynamix.motion.Tweensy; import fl.motion.easing.Sine.easeOut; This will animate 'myInstance' from its current x to the x position of 500 in 2 seconds using the Sine.easeOut equation. Additional parameters for ease equationsThe ease equations Back and Elastic are considered special ease equations because they allow additional parameters to be defined to modify the easing equation. TweensyTimeline allows you to define parameters to control this by the classes BackEaseParams and ElasticEaseParams. import com.flashdynamix.motion.; import fl.motion.easing.Back.easeOut; import com.flashdynamix.motion.easing.BackEaseParams; This will animate 'myInstance' from it's current x to the x position of 500 in 2 seconds using the Back.easeOut equation and dampen the overshoot of the equation by a factor of 0.7. Delaying a tweenAll tweens can have a start and end delay by default they will do not have any. import com.flashdynamix.motion.; This will animate 'myInstance' to the x position of 500 after a starting delay of 1 second with another 1.5 second ending delay before the animation is considered complete. Doing an advanced tweenTweening the properties of certain Objects in Actionscript can be more complicated these Objects include BitmapFilters, ColorTransforms, Matrices and SoundTransforms to name a few. This is because tweening the property's of these Objects need to be applied onto another for them to have a visual effect. Though Tweensy can do this, it requires you to define an extra parameter to define which Object to update onto. Tweensy.to(new DropShadowFilter(), {blurX:10, blurY:10}, 2.0, null, 0, myInstance); Tweens the blurX and blurY properties for the DropShadowFilter and applies the drop shadow onto myInstance. var mtx:Matrix = myInstance.transform.matrix; mtx.tx = 200; mtx.ty = 200; Tweensy.to(myInstance.transform.matrix, mtx, 2.0, null, 0, myInstance); Tweens the tx and ty properties for the Matrix of myInstance and applies the matrix transformation onto myInstance. var ct:ColorTransform = myInstance.transform.colorTransform; ct.redOffset = 80; Tweensy.to(myInstance.transform.colorTransform, ct, 2.0, null, 0, myInstance); Tweens the redOffset property for the ColorTransform of myInstance and applies the color transform onto myInstance. var st:SoundTransform = myChannel.soundTransform; st.volume = 0; Tweensy.to(myChannel.soundTransform, st, 2.0, null, 0, myChannel); Tweens the volume property for the SoundTransform of a SoundChannel and applies the sound transform onto myChannel. Adding and removing tween eventsTweensy and Timelines have 2 events update and complete. Update fires every time the tween is updated and complete fires when the animation is finished. Predefined parameters may be applied to each of these functions as they are fired if none are defined, no parameters are applied. Events for TweensyonUpdate will fire each render of an Event.ENTER_FRAME. import com.flashdynamix.motion.; Events for TweensyTimelineonUpdate will fire each time the timeline animation updates. import com.flashdynamix.motion.; To remove a onComplete or onUpdate event simply set it back to null. timeline.onComplete = null; Tweensy uses this method of applying event listeners rather than the Adobe Event Dispatcher as it allows for predefined parameters allowing for self removing tweens without all the fussiness of using the EventDispatcher first i.e. import com.flashdynamix.motion.; Using TweensyGroupTweensyGroup is the recommended implementation of tweening and offers all the functionality of Tweensy (and more) but doesn't provide it's functionality by static methods and properties. As the animations contained within the TweensyGroup instance are only the ones defined by this instance it provides a greater level of control over animations. This means TweensyGroup allows for stopping, pausing and setting specific refreshTypes which only effect this TweensyGroup instance. It's also important to remember as TweensyGroup is weakly referenced it is important you maintain an instance and dispose it when its no longer used. var tween:TweensyGroup = new TweensyGroup();
tween.to(myInstance, {x:500}); Other benefits of using TweensyGroupTweensyGroup contains a collection of functions which shortcut otherwise advanced concepts of the Tweensy engine. Some of these include :
Disposing TweensyGroupAs the TweensyGroup class is constructed it's important that you dispose the class when you are done with it. import com.flashdynamix.motion.; Lazy mode with TweensyGroupTweensy by default automatically resolves tweening conflicts though this comes at a performance cost. If this feature is turned off it can improve the overall performance of Tweensy. This mode is considered lazy tween conflict resolution because when its off it's up to the developer to stop tweens for a particular instance by the stop method. var tween:TweensyGroup = new TweensyGroup(false); Will disable automatic resolution of tweening conflicts. Object pooling with TweensyGroupPart of the reason why Tweensy is so memory efficient is it has the option to use Object pooling by default this option is off. This is because using Object pooling is a rather advanced feature not suited to novice developers. For more experienced developers it is recommended to use this feature. But it's important to note that TweensyGroup pools instances of TweensyTimeline and the implications this may have. If constant references are made to an instance of TweensyTimeline this could create logical problems in your code. This is because after the TweensyTImeline instance is initially used for your animation it may be used again for another. var tween:TweensyGroup = new TweensyGroup(false, true); This will enable Tweensy to use Object pooling. Motion guided tweensTweensy has a package called guides which allow for defining a direction, orbit or bezier path to be used on a motion tween. Direction guided tweensA direction guide has a direction and a distance. Tweening the position on the Direction2D class defines where on the path the item is placed initially the path is at position 0 and ends at position 1. import com.flashdynamix.motion.;
import com.flashdynamix.motion.guides.Direction2D;
var tween:TweensyGroup = new TweensyGroup();
tween.to(new Direction2D(myInstance, 45, 100), {position:1}); This will animate 'myInstance' a distance of 100 pixels at 45 degree from it's current position. Orbit guided tweensAn orbit guide has a radius x, radius y, center x and a center y. Tweening the angle in degrees on the Orbit2D class defines where on the path the item is placed initially the path is at the angle 0. import com.flashdynamix.motion.; import com.flashdynamix.motion.guides.Orbit2D; This will orbit 'myInstance' 360 degrees on a x/y radius of 100 from the x/y center point of 250. Bezier guided tweensA bezier guide has a collection of points defining a bezier path. Tweening the position on the Bezier2D class defines where on the path the item is placed initially the path is at position 0 and ends at position 1. import com.flashdynamix.motion.; import com.flashdynamix.motion.guides.Bezier2D; This will animate 'myInstance' along the bezier path defined from it's start position. Advanced Matrix and ColorMatrixFilter tweensTweensy has a package called extras which contains classes which help you to do complicated animations in a very easy manner. These tweens include Matrix transformations around a registration point. As well ColorMatrixFilter effects such as brightness, contrast, colorize and threshold. Advanced Matrix tweensAn advanced Matrix tween allows for applying Matrix transformations around a defined registration point. These transformations include rotation, skewX, skewY, scaleX, scaleY, translationX and translationY. import com.flashdynamix.motion.; import com.flashdynamix.motion.extras.MatrixTransform; This will tween 'myInstance' rotation to 45 degrees around the middle of 'myInstance'. ColorMatrixFilter tweensThe ColorMatrixFilter allows for applying complex color alterations like brightness, contrast, saturation, colorize and threshold. The ColorMatrix class helps to create the 4x5 Array matrix to then be tweened onto a ColorMatrixFilter. import flash.filters.ColorMatrixFilter; import com.flashdynamix.motion.; import com.flashdynamix.motion.extras.ColorMatrix; This will tween the ColorMatrixFilter from the identity matrix to the Array matrix defined by ColorMatrix and apply the ColorMatrixFilter to 'myInstance' Using TweensySequenceTweensySequence allows for a chain of tweens to occur one after another. Like TweensyGroup, TweensySequence must be constructed in order to be used. Once a sequence has been created you can then start, stop, pause or resume the sequence at any time. As well repeat via the modes replay and yoyo. import com.flashdynamix.motion.TweensySequence; Creates a tween sequence for 'myInstance' taking 1 second to move between each of the positions pushed into the sequence. |
Bezier guided tweens typo. Missing some right braces
var tween:TweensyGroup = new TweensyGroup(); var bezier:Bezier2D = new Bezier2D(myInstance, true, false, false); bezier.push(new Point(100, 100)); bezier.push(new Point(200, 150)); bezier.push(new Point(300, 100)); bezier.push(new Point(400, 300)); tween.to(bezier, {position:1});Great work. been using tweensy lately with much success. Quick question regarding Tweensy Sequence: Let's say I have a sequence but want to have a Group as one of the steps in the sequence. How would you recommend doing that. Specifically the issue I ran into was wanting to have one step affect the BlurFilter? and the x,y position. I can't see anyway to do that with tweensy sequence. Maybe you could allow TweensyGroups? to be added to sequence with push, unshift ? Currently Im just using my own sequencer to get around this but is there something I'm missing?
Hey Andrew, thanks for picking up the typo error, blush :)
We are currently rebuilding the sequencer to make it far more flexible and powerful to include such features but thanks for the feedback those are all great ideas.
Is there any information how to do a SHAPE TWEEN using Tweensy? I read its one of Tweensy's unique features. What I am looking for is a way to modify the CurveTo?-Points of a Sprite.grahics object I have drawn over time... so that it becomes a vector shape tween..... you know. thanks
Any news on how to add tweensygroups to a sequence?
Do you have analog of delayedCall() function from TweenLite?? It is very useful for me and I think not so hard to make this stuff.
Hey man thanks for this powefull and smart tool, it's really really great.. i just have one question about this, cause i'am having a problem and i don't know if it's occur cause i have multiples instances of Tweensy that i applied to a different objects and in certain point the interactive animationstop.. and i dont know why this happend.? what can i do to fix this.? any suggestion?? Thanks a lot for the answer that you can bring me. PD: about my animation it's a papervision project and i'am animating the camera making a zoom and changing uniformly the color of the objects thats appear in the 3d scenarie, and i'am using 2 tweensys, a tweensy for the camera and other for all the objects. att. juliop@idprojectweb.com
How do you tween an ininstance with blur and movement at the same time: 1. - move from A to B in 2 sec 2. - blur from A to B/2 in 1 sec 3. - blur from B/2 to B in 1 sec So how can you add 2 blurs in a sequence ? I tried and it didn't work. var sequenceBlur:TweensySequence? = new TweensySequence?(); sequenceBlur.push(myInstance, Tweensy.to(new BlurFilter?(), {blurX:200, blurY:10}, 1.0, null, 0, myInstance), 1); sequenceBlur.push(myInstance, Tweensy.to(new BlurFilter?(), {blurX:200, blurY:10}, 1.0, null, 0, myInstance), 1); sequenceBlur.start();
Simple put: how can you add 2 blurs in a sequence ?
Couldn't find a on 'CHANGE' event. Like the Adobe one has the 'TweenEvent?.MOTION_CHANGE' So far I see Tweensy has onComplete, onUpdate, onRepeat.
Any suggestions of what I could use to get change events?
I want to tween my own public vars. Is this possible in Tweensy? I can't get it to work.
I figured it out. You have to initialize the var.
First: Great framework! But please add some example on how to use a custom easing equation that is using an array from "Custom Easing Tool". I somehow cant figure it out and cant find anything on the web about this.
Just to make sure I got this right, if you have a tween toggle on a object, do I really need to do like this to make it go from "current" alpha to desired alpha? If i do not use the stop method, it goes nuts if I constantly move the mouse over my object.
// Mouse Over Tweensy.stop(instance); Tweensy.to(instance, {alpha: 1});
// Mouse Out Tweensy.stop(instance); Tweensy.to(instance, {alpha: 0});