Packagecom.greensock.plugins
Classpublic class TweenPlugin
InheritanceTweenPlugin Inheritance Object
Subclasses AutoAlphaPlugin, BezierPlugin, CacheAsBitmapPlugin, CirclePath2DPlugin, DirectionalRotationPlugin, DynamicPropsPlugin, EndArrayPlugin, EndVectorPlugin, FrameForwardPlugin, FramePlugin, HexColorsPlugin, LiquidPositionPlugin, MotionBlurPlugin, OnChangeRatioPlugin, OnCompleteRenderPlugin, Physics2DPlugin, PhysicsPropsPlugin, Positions2DPlugin, QuaternionsPlugin, RoundPropsPlugin, ScalePlugin, ScrambleTextPlugin, ScrollRectPlugin, SetActualSizePlugin, SetSizePlugin, ShortRotationPlugin, SoundTransformPlugin, StageQualityPlugin, ThrowPropsPlugin, TintPlugin, TransformAroundPointPlugin, TransformMatrixPlugin, VisiblePlugin, VolumePlugin

TweenPlugin is the base class for all TweenLite and TweenMax plugins, but generally isn't used directly.

USAGE:

To create your own plugin, extend TweenPlugin and override whichever methods you need. Typically, you only need to override _onInitTween() (which is called when the tween renders for the first time) and setRatio() (which is called on every update and passes a progress parameter which is typically a value between 0 and 1, but changes according to the ease). I'd recommend looking at a simple plugin like ScalePlugin and using it as a template of sorts. There are a few key concepts to keep in mind:

  1. Pass the TweenPlugin constructor a comma-delimited list of property names that the plugin should overwrite, the first of which should be the property name that the plugin intercepts. For example, the ScalePlugin handles any tweens of "scale" and it also overwrites other concurrent tweens that are handling the "scale", "scaleX", and/or "scaleY" properties of the target. Therefore, in ScalePlugin's constructor, we'd call super("scale,scaleX,scaleY"). The first name in the list must be unique - two plugins cannot handle the same primary property.
  2. When a tween that uses your plugin initializes its tween values (normally when it renders the first time), a new instance of your plugin will be created and the _onInitTween() method is called. That's where you'll want to record any initial values and prepare for the tween. _onInitTween() should return a Boolean value that essentially indicates whether or not the plugin initted successfully. If you return false, TweenLite/Max will just use a normal tween for the value, ignoring the plugin for that particular tween. For example, maybe your tween only works with MovieClips, so if the target isn't a MovieClip you could return false
  3. The setRatio() method will be called on every frame during the course of the tween and it will be passed a single parameter that's a multiplier (typically between 0 and 1, according to the ease) describing the total amount of change from the beginning of the tween (0). It will be zero at the beginning of the tween and 1 at the end, but inbetween it could be any value based on the ease applied (for example, an ElasticOut ease would cause the value to shoot past 1 and back again before the end of the tween). So if the tween uses the Linear.ease, when it's halfway finished, the setRatio() will receive a parameter of 0.5.
  4. The _overwriteProps is an array that should contain the properties that your plugin should overwrite in "auto" mode. For example, the autoAlpha plugin controls the "visible" and "alpha" properties of an object, so if another tween is created that controls the alpha of the target object, your plugin's _kill() method will be called which should handle killing the "alpha" part of the tween. It is your responsibility to populate (and depopulate) the _overwriteProps Array. Failure to do so properly can cause odd overwriting behavior.
  5. There's a _roundProps() method that gets called by the RoundPropsPlugin if the user requests that certain properties get rounded to the nearest integer. If you use _addTween() method to add property tweens, rounding will happen automatically (if necessary), but if you don't use _addTween() and prefer to manually calculate tween values in your setRatio() method, just remember to override the _roundProps() method if that makes sense in your plugin (some plugins wouldn't need to accommodate rounding, like color plugins).
  6. If you need to run a function when the tween gets disabled, add an _onDisable() method (named exactly that) to your plugin. It will automatically be called when the tween gets disabled (typically when it finishes and is removed from its parent timeline). Same for _onEnable() if you need to run code when a tween is enabled. These methods should return a Boolean value indicating whether or not they changed any properties on the target becaues if so (true), it helps notify any initting tweens of the same target to re-init. It is very rare that an _onDisable() or _onEnable() method is necessary, but it can be useful for things like MotionBlurPlugin which must do some very advanced things, hiding the target, changing its alpha to almost 0, etc. only while the tween occurs. If another alpha tween of that same target overwrites an existing motionBlur of the same target, the alpha would be at the wrong value normally, but the if the _onDisable() returns true, it would force the new tween to re-init AFTER the alpha was fixed inside the _onDisable(). Again, this is VERY rare.
  7. Please use the same naming convention as the rest of the plugins, like MySpecialPropertyNamePlugin.
  8. If you are handling more than one property in your plugin (like RoundPropsPlugin or ShortRotationPlugin), make sure you override the _kill() method which will be passed a vars parameter with properties that need to be killed (typically for overwriting).

Copyright 2008-2013, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for Club GreenSock members, the software agreement that was issued with the membership.



Public Methods
 MethodDefined By
  
activate(plugins:Array):Boolean
[static] Activates one or more plugins so that TweenLite and TweenMax recognize the associated special properties.
TweenPlugin
Method Detail
activate()method
public static function activate(plugins:Array):Boolean

Activates one or more plugins so that TweenLite and TweenMax recognize the associated special properties. You only need to activate each plugin once in order for it to be used in your project/app. For example, the following code activates the ScalePlugin and RoundPropsPlugin:

TweenPlugin.activate([ScalePlugin, RoundPropsPlugin]);

Thereafter, tweens will recognize the "scale" and "roundProps" special properties associated with these plugins. Like TweenLite.to(mc, 1, {scale:5, x:300, roundProps:"x"});

Each plugin must extend TweenPlugin.

Parameters

plugins:Array — An Array of plugins to be activated. For example, TweenPlugin.activate([FrameLabelPlugin, ShortRotationPlugin, TintPlugin]);

Returns
Boolean