setTimeScale()

Availability

AS2 and AS3.

Usage

Tweener.setTimeScale(scale:Number);

Parameters

scale:Number — Any number higher than 0. The default value (for a normal time scale) is 1; if this parameter is omitted, it is assumed to be 1.

Description

Sets the global time scale for transition execution (both the time and delay expected for tweens). This works by changing the time scale in which the tweening engine relies; when this method is called, all existing tweenings are updated, and new ones will also follow the new time scale. The scale is an absolute value.

The default value is 1, which assumes a normal time scale. A value of 2 puts the tweening engine in a fast-forward mode, where all tweens take half the original time to complete. A value of 0.5 makes all tweenings take two times the original time, resulting in a slow-motion appearance.

This method works globally, so it should only be used on very specific cases. It was implemented mainly for debugging purposes; for example, if you have a long animation and you don't want to wait for it to complete, you can set the time scale to a high number before it starts, and then set it back to 1 when it ends. You can also attach that toggle to specific keys, or only use it when testing locally. Of course, you can do little tweaks to your movie's general time scale, but it's not recommended as it works on all your transitions as a whole.

Returns

Nothing.

Examples

// Makes your movie tweenings go into turbo mode
Tweener.setTimeScale(10);
// Makes all animation slower only when you're testing on the Flash IDE
if (System.capabilities.playerType == "External") Tweener.setTimeScale(0.5)
// Create a toggle that makes your movie go faster when SHIFT is pressed
Key.addListener(this);
this.onKeyDown = function() {
	if (Key.isDown(Key.SHIFT)) Tweener.setTimeScale(10);
}
this.onKeyUp = function() {
	if (!Key.isDown(Key.SHIFT)) Tweener.setTimeScale(1);
};