TweenMax介绍

Tweenmax是TweenLite和TweenFilterLite的基础上建立的。目的在于使得tweening家族具备更加大众化的功能......Tweenmax同样使用简单易学的语法。实际上,因为Tweenmax是演化版,所以TweenMax可以实现TweenLite和 TweenFilterLite的所有功能,或者更多。那么,你可能要问,为什么不仅仅弄一个类呢?这是个很好的问题。这是因为我们的目的在于用最小的代码实现最好的效果。坦白说,90%的项目可能需要TweenLite,一个3K的类。这使得整个项目非常高效率地简单的实现需要的效果。但是如果你需要 tween filters或者更多的效果......就要用到6K大小的TweenFilterLite。还要更多功能?没问题,使用9K大小的(看起来十分臃肿的?)TweenMax实现更多功能。下面的列表展示了这三个类之间的不同之处。TweenMax引入了一项创新的功能,叫做 "bezierThrough",一个能够让你通过运动曲线定义相关的点(而不是用普通的方法......)又或者用有规律的贝赛尔曲线-只要你愿意。它甚至会处理你的物体的旋转,来调整你的方向。看看下面的例子吧。点击添加贝赛尔点。

方法

TweenMax.to(target:Object, duration:Number, variables:Object):TweenMax 
-- 描述:让你的物体的属性从你声明这个方法时的状态变到任何你设定的效果。 
-- 参数: 
          ---- target:Object :你想要实现动画的目标物体 
          ---- duration:Number :整个过程的时间(seconds) 
          ---- variables:Object :一个包括最终的所有你想得到的属性(如果你正在用TweenMax.from()这个方法,这些变量就是初始值。)的Object、 
                    ------ delay:Number :开始动画之前的延时。这在实现多个动画时变得很有用。 
                    ------ ease:Function :You can specify a function to use for the easing with this variable. For example, gs.easing.Elastic.easeOut. The Default is Regular.easeOut. 
                    ------ easeParams:Array :An Array of extra parameter values to feed the easing equation. This can be useful when you use an equation like Elastic and want to control extra parameters like the amplitude and period. Most easing equations, however, don't require extra parameters so you won't need to pass in any easeParams. 
                    ------ autoAlpha:Number :Use it instead of the alpha property to gain the additional feature of toggling the visible property to false when alpha reaches 0. It will also toggle visible to true before the tween starts if the value of autoAlpha is greater than zero 
                    ------ visible:Boolean : 设置动画结束时物体的visible值。 
                    ------ volume:Boolean : 操控声音大小 
                    ------ tint:unit : 更改物体最终的hex颜色值,(如果用的是TweenMax.from()则是初始值。)tint的值应该像:0xFF0000 
                    ------ removeTint:Boolean : 当你想清楚设定的tint参数是,请将此设为true 
                    ------ frame:int :设置整个动画过程的帧数 
                    ------ bezier:Array :贝赛尔动画使你能够抛开线的束缚(意译)。举个例子,你可能想让一个DisplayObject的位置从原来的(0,0)移到(500,0),但是移动的时候想向下弯曲。只需添加你想要的object到贝赛尔array,每一个object代表一个"控制点"(控制点相关类容请参考Flash的 curveTO()这个画画的方法)在这个例子中,我们假定控制点坐标未(250,0)。只需要让你的my_mc的坐标为(0,0)。然后添加代码: TweenMax.to(my_mc, 3, {_x:500, _y:0, bezier:[{_x:250, _y:50}]}); 
                    ------ bezierThrough:Array : 和bezier同一原理,只是物体运动时会通过bezierThrough设定的点(物体不会通过bezier设定的点),这样就使控制更加直观。 
                    ------ orientToBezier:Array (or Boolean) :设计师/程序开发者一般想要的一个效果就是物体在运动的时候能自动调整自身的方向。(就使更改物体的旋转。)orientToBezier是这个变得很简单。为了准确地自动调整方向,TweenMax需要4条信息: 
                    -------- Position property 1 (即为"x") 
                    -------- Position property 2 (即为"y") 
                    -------- Rotational property (即为"rotation") 
                    -------- Number of degrees to add (可选 - 让你更好的控制你的物体) 
        orientToBezier这个属性应该是一个容器数组(Array),这个数组应包含至少一个子数组,而这个子数组则包含上述四个信息。为了最好的兼容性,你可以在这个容器数组里面输入任何数字,每一个都代表旋转属性。这在处理3D时十分便利。以为你可以在多重方向轴上旋转。如果你的项目是普通的2D (X/Y)贝赛尔运动,你可以只输入一个布尔值true,TweenMax就会自动创建一个数组[["x", "y", "rotation", 0]]。提示:不要忘记容器数组(就是一共有两层中括号[]) 
                    ------ hexColors:Object :尽管hex颜色是纯粹的数字。但你想使它们成为你的动画一部分(意译),你就会发现它们并不流畅地变化。为了让它们流畅地变化,红、绿、蓝通道必须分离,并单独的变化。在TweenMax里,这很简单。让你的物体从一种颜色变化到另一种颜色,运用hexColors属性就可以了。这个属性必须为一个 Object,Object的属性必须和你的物体的hex颜色的属性一致。举个例子:假如你的Object,my_obj有一个名为 "myHexColor"的属性,而你想在两秒内编程红色(0xFF0000),输入代码:TweenMax.to(my_obj, 2, {hexColors:{myHexColor:0xFF0000}}); 你可输入任何hexColor属性。 
                    ------ onStart:Function :如果你想在动画开始时调用一个函数,就在这里输入调用。如果动画开始前有延时,并且你想在那段时间弄点什么,这变得非常用。 
                    ------ onStartParams:Array :onStart调用的函数的参数 
                    ------ onStartListener:Function :一个TweenMax实例在动画开始时调用的函数。这就好比输入:TweenMax.to(my_obj, 2, {hexColors:{myHexColor:0xFF0000}}); 
                    ------ onUpdate : Function :如果你想在属性每次变化时调用一个函数(on every frame during the time the tween is active)就在这里输入一个函数调用。 
                    ------ onUpdateParams : Array :onUpdate调用的函数的参数(可选)。 
                    ------ onUpdateListener : Function :一个TweenMax实例在属性每次变化时调用的函数。这就好比输入:myTweenMaxInstance.addEventListener (TweenEvent.Update, myFunction); 
                    ------ onComplete : Function :动画结束时调用的函数。 
                    ------ onCompleteParams : Array :参考onUpdateParams : Array 
                    ------ onCompleteListener : Function :参考onUpdateListener : Function 
                    ------ persist : Boolean : 如果设置为true, TweenMax实例不会自动被垃圾回收。但即使设置为true,它仍然会被信的tween覆盖。默认为false 
                    ------ renderOnStart:Boolean :假如你用的是TweenMax.from(),并且在开始之前有延时,还有就是你希望在延时之后才开始渲染,就应设为true,默认为 false which causes TweenMax.from() to render its values immediately, even before the delay has expired. 
                    ------ overwrite : Boolean : If you do NOT want the tween to automatically overwrite any other tweens that are affecting the same target, make sure this value is false. 
                    ------ blurFilter : Object - To apply a BlurFilter, pass an object with one or more of the following properties: 
                             -------- blurX 
                             -------- blurY 
                             -------- quality 
                    ------ glowFilter : Object - To apply a GlowFilter, pass an object with one or more of the following properties: 
                             -------- alpha 
                             -------- blurX 
                             -------- blurY 
                             -------- color 
                             -------- strength 
                             -------- quality 
                             -------- inner 
                             -------- knockout 
                    ------ colorMatrixFilter : Object - To apply a ColorMatrixFilter, pass an object with one or more of the following 
                             -------- properties: 
                             -------- colorize 
                             -------- amount 
                             -------- contrast 
                             -------- brightness 
                             -------- saturation 
                             -------- hue 
                             -------- threshold 
                             -------- relative 
                             -------- matrix 
                    ------ dropShadowFilter : Object - To apply a DropShadowFilter, pass an object with one or more of the following -------- properties: 
                             -------- alpha 
                             -------- angle 
                             -------- blurX 
                             -------- blurY 
                             -------- color 
                             -------- distance 
                             -------- strength 
                             -------- quality 
                   ------ bevelFilter : Object - To apply a BevelFilter, pass an object with one or more of the following properties: 
                             -------- angle 
                             -------- blurX 
                             -------- blurY 
                             -------- distance 
                             -------- highlightAlpha 
                             -------- highlightColor 
                             -------- shadowAlpha 
                             -------- shadowColor 
                             -------- strength 
                             -------- quality

TweenMax.from(target:Object, duration:Number, variables:Object):TweenMax 
--描述: Exactly the same as TweenMax.to(), but instead of tweening the properties from where they're at currently to whatever you define, this tweens them the opposite way - from where you define TO where ever they are now (when the method is called). This is handy for when things are set up on the stage the way the should end up and you just want to tween them to where they are. 
--参数: Same as TweenMax.to(). (see above)

TweenMax.sequence(target:Object, tweenObjects:Array):Array 
--描述: 一系列的tween事件。Provides an easy way to sequence a set of tweens, one after the other. It's essentially the same thing as making a bunch of individual TweenMax.to() calls on the object with overwrite set to false, and the delays stacked. 
--参数
          ---- target : Object : The object whose properties to tween. 
          ---- tweenObjects : Array : An array of tween objects. IMPORTANT: each object must contain a "time" property defining the duration of that tween. Example: TweenMax.sequence(mc, [{time:1, x:"200"}, {time:2, autoAlpha:0, onComplete:myFunction}]);

TweenMax.multiSequence(target:Object, tweenObjects:Array):Array 
--描述: 和TweenMax.sequence(),不同在于能操控不同对象。Same as sequence() except it allows each tween in the sequence to have a different target. 
--参数
          ---- tweenObjects : Array - An array of tween objects. IMPORTANT: each object must contain a "time" property defining the duration of that tween AND a "target" property defining the Object that the tween pertains to. Example: TweenMax.multiSequence([{target:mc1, time:1, x:"200"}, {target:mc2, time:2, autoAlpha:0, onComplete:myFunction}]);

TweenMax.allTo(targets:Array, duration:Number, vars:Object):Array 
--描述: 同一变换应用到不同物体。Provides an easy way to tween multiple objects to the same values. It also accepts a few special properties, one of which is "delayIncrement" which staggers the start time of each tween. For example, you might want to have 5 MovieClips move down 100 pixels while fading out, and stagger the start times slightly by 0.2 seconds, you could do: TweenMax.allTo([mc1, mc2, mc3, mc4, mc5], 1, {y:"100", alpha:0, delayIncrement:0.2}); 
--参数: 
          ---- targets : Array - An array of objects to tween. 
          ---- duration : Number - Duration (in seconds) of the tween 
          ----vars : Object - An object containing the end values of all the properties you'd like to have tweened (or if you're using the TweenMax.allFrom() method, these variables would define the BEGINNING values). 
               -----Special Properties: 
                  ------- IMPORTANT: Accepts the exact same special properties as the to() and from() methods (see list above), and adds these: 
                  ------- delayIncrement : Number - delay (in seconds) between each tween's start time. This is useful for staggering the tweens. 
                  ------- onCompleteAll : Function - If you'd like to call a function when ALL of the tweens have finished, use this. 
                  ------- onCompleteAllParams : Array - An array of parameters to pass the onCompleteAll function

TweenMax.allFrom(targets:Array, duration:Number, vars:Object):Array 
--描述: Exactly the same as TweenMax.allTo(), but instead of tweening the properties from where they're at currently to whatever you define, this tweens them the opposite way - from where you define TO where ever they are. This is handy for when things are set up on the stage the way they should end up and you just want to tween them into place. 
--参数: Same as TweenMax.allTo(). (see above)

pause():void 
--描述: 暂停。Pauses the tween. When a tween is paused, it's "paused" property is set to true.

resume():void 
--描述: 恢复。Resumes a paused tween. When a tween is resumed, it's "paused" property is set to false.

addEventListener(type:String, listener:Function, useCapture:Boolean, priority:int, useWeakReference:Boolean):void 
--描述: 添加侦听器。Adds a TweenEvent listener.

removeEventListener(type:String, listener:Function):void 
--描述: 删除侦听器。Removes a TweenEvent listener. See the Flash documentation to learn about the removeEventListener() parameters.

TweenMax.getTweensOf(target:Object):Array 
--描述: 获得一个关于某对象的tweens的数组。Gets an array of all tweens affecting the target object. 
--参数: 
          ---- target : Object - The object whose tweens you want to get.

TweenMax.isTweening(target:Object):Boolean 
--描述: Checks to see if a particular object is currently being tweened (paused tweens don't count). 
--参数
          ---- target : Object - The object whose tweens you want to check.

TweenMax.getAllTweens():Array 
--描述: Returns an array of all tweens (including paused tweens).

TweenMax.delayedCall(delay:Number, onComplete:Function, onCompleteParams:Array); 
--描述: 某一段时间后调用指定函数。Provides an easy way to call any function after a specified number of seconds. Any number of parameters can be passed to that function when it's called too. 
--参数
          ---- delay : Number - Number of seconds before the function should be called. 
          ---- onComplete : Function - The function to call 
          ---- onCompleteParams : Array - [optional] An array of parameters to pass the onComplete function when it's called.

TweenMax.killTweensOf(target:Object, complete:Boolean); 
--描述: 删除指定物体的tween。Provides an easy way to kill all tweens of a particular Object/MovieClip. You can optionally force it to immediately complete (which will also call the onComplete function if you defined one) 
--参数: 
          ---- target : Object - Any/All tweens of this Object will be killed. 
          ---- complete : Boolean - If true, the tweens for this object will immediately complete (go to the ending values and call the onComplete function if you defined one).

TweenMax.killDelayedCallsTo(function:Function); 
--描述: Provides an easy way to kill all delayed calls to a particular function (ones that were instantiated using the TweenMax.delayedCall() method). 
--参数: 
          ---- function : Function - Any/All delayed calls to this function will be killed.

TweenMax.killAllTweens(complete:Boolean):void 
--描述: Kills ALL tweens (but not delayedCalls). 
--参数: 
          ---- complete: Boolean - If you'd like to force the tweens to complete, set this to true. (it's false by default)

TweenMax.killAllDelayedCalls(complete:Boolean):void 
--描述: Kills ALL delayedCalls. 
--参数: 
          ---- complete: Boolean - If you'd like to force the delayedCall to complete, set this to true. (it's false by default)

TweenMax.pauseAll(tweens:Boolean, delayedCalls:Boolean):void 
--描述: Provides a way to pause all TweenMax tweens and/or delayedCalls (not TweenLite/TweenFilterLite tweens or delayedCalls). 
--参数: 
          ---- tweens: To pause tweens, set this to true. (it is true by default) 
          ---- delayedCalls: To pause delayedCalls, set this to true. (it is false by default)

TweenMax.resumeAll(tweens:Boolean, delayedCalls:Boolean):void 
--描述: Resumes all TweenMax tweens 
--参数: 
          ---- tweens: To resume tweens, set this to true. (it is true by default) 
          ---- delayedCalls: To resume delayedCalls, set this to true. (it is false by default)

TweenMax.removeTween(tween:TweenLite):void 
--描述: Kills a single tween instance. 
--参数: 
          ---- tween: The TweenMax/TweenFilterLite/TweenLite instance that you'd like to kill.

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值