適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隱藏篩選
mx.effects 

Tween  - AS3 Flex

套件mx.effects
類別public class Tween
繼承Tween Inheritance EventDispatcher Inheritance Object

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1


使用 Flex 4.0 開始,Adobe 建議您使用 spark.effects.animation.Animation 類別當作是此類別的替代類別。

Tween is the underlying animation class for the effects in Flex 3. As of Flex 4, the Spark effects use the spark.effects.animation.Animation class to provide similar functionality.


The Tween class defines a tween, a property animation performed on a target object over a period of time. That animation can be a change in position, such as performed by the Move effect; a change in size, as performed by the Resize or Zoom effects; a change in visibility, as performed by the Fade or Dissolve effects; or other types of animations.

When defining tween effects, you typically create an instance of the Tween class within your override of the EffectInstance.play() method. A Tween instance accepts the startValue, endValue, and duration properties, and an optional easing function to define the animation.

The Tween object invokes the mx.effects.effectClasses.TweenEffectInstance.onTweenUpdate() callback function on a regular interval on the effect instance for the duration of the effect, passing to the onTweenUpdate() method an interpolated value between the startValue and endValue. Typically, the callback function updates some property of the target object, causing that object to animate over the duration of the effect.

When the effect ends, the Tween objects invokes the mx.effects.effectClasses.TweenEffectInstance.onTweenEnd() callback function, if you defined one.

相關 API 元素



公用屬性
 屬性定義自
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
  duration : Number = 3000
Duration of the animation, in milliseconds.
Tween
  easingFunction : Function
[唯寫] Sets the easing function for the animation.
Tween
  listener : Object
Object that is notified at each interval of the animation.
Tween
公用方法
 方法定義自
  
Tween(listener:Object, startValue:Object, endValue:Object, duration:Number = -1, minFps:Number = -1, updateFunction:Function = null, endFunction:Function = null)
Constructor.
Tween
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。
EventDispatcher
 Inherited
會將事件傳送到事件流程。
EventDispatcher
  
Interrupt the tween, jump immediately to the end of the tween, and invoke the onTweenEnd() callback function.
Tween
 Inherited
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。
EventDispatcher
 Inherited
指出物件是否有已定義的指定屬性。
Object
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
  
Pauses the effect until you call the resume() method.
Tween
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
會從 EventDispatcher 物件移除偵聽程式。
EventDispatcher
  
Resumes the effect after it has been paused by a call to the pause() method.
Tween
  
Plays the effect in reverse, starting from the current position of the effect.
Tween
  
seek(playheadTime:Number):void
Advances the tween effect to the specified position.
Tween
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
  
setTweenHandlers(updateFunction:Function, endFunction:Function):void
By default, the Tween class invokes the mx.effects.effectClasses.TweenEffectInstance.onTweenUpdate() callback function on a regular interval on the effect instance for the duration of the effect, and the optional mx.effects.effectClasses.TweenEffectInstance.onTweenEnd() callback function at the end of the effect duration.
Tween
  
Stops the tween, ending it without dispatching an event or calling the Tween's endFunction or onTweenEnd().
Tween
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
 Inherited
會傳回指定之物件的基本值。
Object
 Inherited
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。
EventDispatcher
事件
 事件 摘要 定義自
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式取得作業系統焦點並成為作用中時傳送。EventDispatcher
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式失去作業系統焦點並成為非作用中時傳送。EventDispatcher
屬性詳細資訊

duration

屬性
public var duration:Number = 3000

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Duration of the animation, in milliseconds.

easingFunction

屬性 
easingFunction:Function  [唯寫]

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Sets the easing function for the animation. The easing function is used to interpolate between the startValue value and the endValue. A trivial easing function does linear interpolation, but more sophisticated easing functions create the illusion of acceleration and deceleration, which makes the animation seem more natural.

If no easing function is specified, an easing function based on the Math.sin() method is used.

The easing function follows the function signature popularized by Robert Penner. The function accepts four arguments. The first argument is the "current time", where the animation start time is 0. The second argument is a the initial value at the beginning of the animation (a Number). The third argument is the ending value minus the initial value. The fourth argument is the duration of the animation. The return value is the interpolated value for the current time (usually a value between the initial value and the ending value).

Flex includes a set of easing functions in the mx.effects.easing package.



實作
    public function set easingFunction(value:Function):void

listener

屬性 
public var listener:Object

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Object that is notified at each interval of the animation.

建構函式詳細資料

Tween

()建構函式
public function Tween(listener:Object, startValue:Object, endValue:Object, duration:Number = -1, minFps:Number = -1, updateFunction:Function = null, endFunction:Function = null)

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Constructor.

When the constructor is called, the animation automatically starts playing.

參數
listener:Object — Object that is notified at each interval of the animation. You typically pass the this keyword as the value. The listener must define the onTweenUpdate() method and optionally the onTweenEnd() method. The former method is invoked for each interval of the animation, and the latter is invoked just after the animation finishes.
 
startValue:Object — Initial value(s) of the animation. Either a number or an array of numbers. If a number is passed, the Tween interpolates between this number and the number passed in the endValue parameter. If an array of numbers is passed, each number in the array is interpolated.
 
endValue:Object — Final value(s) of the animation. The type of this argument must match the startValue parameter.
 
duration:Number (default = -1) — Duration of the animation, expressed in milliseconds.
 
minFps:Number (default = -1) — Minimum number of times that the onTweenUpdate() method should be called every second. The tween code tries to call the onTweenUpdate() method as frequently as possible (up to 100 times per second). However, if the frequency falls below minFps, the duration of the animation automatically increases. As a result, an animation that temporarily freezes (because it is not getting any CPU cycles) begins again where it left off, instead of suddenly jumping ahead.
 
updateFunction:Function (default = null) — Specifies an alternative update callback function to be used instead of listener.OnTweenUpdate()
 
endFunction:Function (default = null) — Specifies an alternative end callback function to be used instead of listener.OnTweenEnd()
方法詳細資訊

endTween

()方法
public function endTween():void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Interrupt the tween, jump immediately to the end of the tween, and invoke the onTweenEnd() callback function.

pause

()方法 
public function pause():void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Pauses the effect until you call the resume() method.

resume

()方法 
public function resume():void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Resumes the effect after it has been paused by a call to the pause() method.

reverse

()方法 
public function reverse():void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Plays the effect in reverse, starting from the current position of the effect.

seek

()方法 
public function seek(playheadTime:Number):void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Advances the tween effect to the specified position.

參數

playheadTime:Number — The position, in milliseconds, between 0 and the value of the duration property.

setTweenHandlers

()方法 
public function setTweenHandlers(updateFunction:Function, endFunction:Function):void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

By default, the Tween class invokes the mx.effects.effectClasses.TweenEffectInstance.onTweenUpdate() callback function on a regular interval on the effect instance for the duration of the effect, and the optional mx.effects.effectClasses.TweenEffectInstance.onTweenEnd() callback function at the end of the effect duration.

This method lets you specify different methods as the update and the end callback functions.

參數

updateFunction:Function — Specifies the update callback function.
 
endFunction:Function — Specifies the end callback function.

stop

()方法 
public function stop():void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Stops the tween, ending it without dispatching an event or calling the Tween's endFunction or onTweenEnd().





[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。