ApplyTweensTimer

Package:
Class:
Inheritance:
biz.flashscript.tweens
public class ApplyTweensTimer
Sprite
The ApplyTweensTimer class is used to create alpha, x, y or x-y tweens with possibility of easing for x, y or alpha. To create an instance of the ApplyTweensTimer use the constructor new ApplyTweens(arguments). The class also allows to dispatch an event when the action is completed. This class uses the Flash.utils.Timer class. The ApplyTweens class, instead uses the ENTER_FRAME event. Both classes can cooperate to achieve multiple tweens.

See also

   biz.flashscript.tweens.ApplyTweens

Public Properties
Property Defined By
xAlpha : Number
The starting alpha value for fade in or out.
ApplyTweensTimer
xPosition : int
The x position to move the instance to.
ApplyTweensTimer
yPosition : int
The y position to move the instance to.
ApplyTweensTimer
easeOut : Boolean
To include easing out.
ApplyTweensTimer
easeIn : Boolean
To include easing in.
ApplyTweensTimer
Public Methods
Method Defined By
ApplyTweensTimer(target:Object, myDuration:int, type:String, delay:int, repeatCount:int)
Creates a new instance of the ApplyTweensTimer class.
ApplyTweensTimer
initTweens()
Will initiate the tween when an instance of the ApplyTweensTimer class exists.
ApplyTweensTimer
Events
Event Defined By

callBack

This event is dispatched when the tween action is finished.

ApplyTweensTimer
All inherited events for the Sprite class. N/A
Property Detail
xAlpha property
xAlpha:Number [read-write]

This sets the initial value for the alpha fading.

For fading in the default value is 0, for fading out myTarget.alpha.

.

Implementation

public function get xAlpha():Number
public function set xAlpha(value:Number):void

xPosition property
xPosition:int [read-write]

This is the x position for the object to move to.

The default value is 0.

Implementation

public function get xPosition():int
public function set xPosition(value:int):void

yPosition property
yPosition:int [read-write]

This is the y position for the object to move to.

The default value is 0.

Implementation

public function get yPosition():int
public function set yPosition(value:int):void

easeOut property
easeOut:Boolean [read-write]

To add easing out behaviour set easeOut to true.

The default value is false.

Implementation

public function get easeOut():Boolean
public function set easeOut(value:Boolean):void

easeIn property
easeIn:Boolean [read-write]

To add easing in behaviour set easeIn to true.

The default value is false.

Implementation

public function get easeIn():Boolean
public function set easeIn(value:Boolean):void
Constructor Detail
ApplyTweensTimer ()  Constructor
public function ApplyTweens(target:Object, myDuration:int, type:String, delay:int, repeatCount:int)
Intializes a new ApplyTweensTimer instance.

Parameters

  • target:Object ____ The tween target, for example a Sprite or MovieClip object.
  • myDuration:int ____ The duration of the tween.
  • type:String="linear" ____ The type of the tween:"alphaIn" (fading in), "alphaOut" (fading out), "xMove" (moving x direction), "yMove" (moving y direction), "xyMove" (moving both directions simultanously.
  • delay:int ____ The frequency of the timer event.
  • repeatCount:int ____ The number of timer events.
Method Detail

initTweens ():void  method
public function initTweens()

This method will initiate the tweening methods. To change certain properties add the property before the method call:

ax.easeIn=true;
ax.initTweens();
Event Detail

callBack event

Event Object Type: biz.flashscript.tweens.ApplyTweensTimer
Event.type property = biz.flashscript.tweens.ApplyTweensTimer.CALL_BACK

Dispatched when the tween is finished.

Examples
The following example demonstrates how to use the ApplyTweens and ApplyTweensTimer class simultanously. Create a new fla file and name it ApplyTweenTimer.fla. Place the fla in the same folder as the biz folder. Create a MovieClip Clip and export for actionscript. Place a button component on the timeline and name it startBut. Then create an Actionscript file, name it ApplyTweenTimer.as and place this script.
package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import biz.flashscript.tweens.ApplyTweens;
	import biz.flashscript.tweens.ApplyTweensTimer;
	import fl.controls.Button;
	import flash.events.MouseEvent;

	public class ApplyTweenTimer extends Sprite
	{
		private var mc:Clip;
		private var xPosition:int;
		private var yPosition:int;
		public var startBut:Button;
		
		public function ApplyTweenTimer ():void
		{
			startBut.label = "START";
			startBut.addEventListener (MouseEvent.CLICK, clickHandler);
			mc = new Clip();
			xPosition = mc.x;
			yPosition = mc.y;
			addChild (mc);
		}
		private function clickHandler (event:MouseEvent):void
		{
			var ax:ApplyTweens = new ApplyTweens(mc,20,"xyMove");
			var at:ApplyTweensTimer = new ApplyTweensTimer(mc,75,"alphaOut",10,1000);
			at.finalAlpha = 0.2;
			ax.xPosition = 400;
			ax.yPosition = 100;
			ax.easeIn = true;
			ax.initTweens ();
			at.initTweens ();
			at.addEventListener (ApplyTweensTimer.CALL_BACK, callHandler);
		}
		private function callHandler (event:Event):void
		{
			trace ("Event: "+event);
			mc.x = xPosition;
			mc.y = yPosition;
			mc.alpha = 1;
		}
	}
}