ApplyTweens

Package:
Class:
Inheritance:
biz.flashscript.tweens
public class ApplyTweens
Sprite
The ApplyTweens 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 ApplyTweens use the constructor new ApplyTweens(arguments). The class also allows to dispatch an event when the action is completed. This class uses the ENTER_FRAME event. The ApplyTweensTimer class, instead uses the Flash.utils.Timer event. Both classes can cooperate to achieve multiple tweens.

See also

   biz.flashscript.tweens.ApplyTweensTimer

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

callBack

This event is dispatched when the tween action is finished.

ApplyTweens
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
ApplyTweens ()  Constructor
public function ApplyTweens(target:Object, myDuration:int, type:String)
Intializes a new ApplyTweens 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.
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.ApplyTweens
Event.type property = biz.flashscript.tweens.ApplyTweens.CALL_BACK

Dispatched when the tween is finished.

Examples
Create a new fla file and name it ApplyTween.fla. Place the fla in the same folder as the biz folder. Create a MovieClip Clip and export for actionscript. Place a component button on the timeline and name it startBut. Then create an Actionscript file, name it ApplyTween.as and place this script.

package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import biz.flashscript.tweens.ApplyTweens;
	import fl.controls.Button;
	import flash.events.MouseEvent;

	public class ApplyTween extends Sprite
	{
		private var mc:Clip;
		private var xPosition:int;
		public var startBut:Button;
		
		public function ApplyTween ():void
		{
			startBut.label = "START";
			startBut.addEventListener (MouseEvent.CLICK, clickHandler);
			mc = new Clip();
			mc.x = 20;
			xPosition = mc.x;
			mc.y = 100;
			addChild (mc);
		}
		private function clickHandler (event:MouseEvent):void
		{
			var ax:ApplyTweens = new ApplyTweens(mc,20,"xMove");
			ax.xPosition = 400;
			ax.easeIn = true;
			ax.initTweens ();
			ax.addEventListener (ApplyTweens.CALL_BACK, callHandler);
		}
		private function callHandler (event:Event):void
		{
			trace ("Event: "+event);
			mc.x = xPosition;
		}
	}
}