Main Page | Packages | Class Tree | Index | Help

com.mosesSupposes.util

class TextFX

Object
  |
  +--com.mosesSupposes.util.TextFX

Implemented Interfaces: IFuseFX

class TextFX
extends Object

TextFX: tween one of this extension's registry keys directly on a TextField instance to affect its current TextFormat.

Usage:
This extension enables interesting effects like tweening the kerning, size, and leading of dynamic text.
import com.mosesSupposes.fuse.*;
import com.mosesSupposes.fusefx.*;
import com.mosesSupposes.util.*;
 
ZigoEngine.register( PennerEasing );
FuseFX.register( MixerFX );
 
// place a textfield onstage with embedded fonts named my_txt
 
// Tween kerning +20 using the engine
// This is equivalent to tweening (my_txt, "textKerningFX",...)
ZigoEngine.doTween(my_txt, TextFX.KERNING, "20", 2, "easeInOutQuint");
 
// You can't use the constants with Fuse's object-literal syntax,
// so instead of TextFX.LEADING you should use the value of the constant "textLeadingFX"
var f:Fuse = new Fuse({ target:my_txt, textLeadingFX:"-4", time:2, ease:"easeInOutQuint" });
f.start();
Tweening a TextField's color can be very useful if you've applied BitmapFilters to the TextField, because tweening any color transform on the TextField results in the filters being colorized as well. TEXT_COLOR is a little bit tricky though, the value MUST register as a colors array in the engine so the value is handled as a hex. For this reason the name of the property is "textColorsArrayFX" instead of "colorX" both as a reminder, and because it is the string "colors" plus using an Array that forces this behavior in the engine.
ZigoEngine.doTween(myTextField, TextFormatTween.TEXT_COLOR, [[0x33FF00]], 1, "easeInQuad");
 
// The same thing in Fuse would read:
myFuse.push({ target:myTextField, textColorsArrayFX:[0x33FF00], time:1, ease:"easeInQuad"});
Note that because doTween accepts an Array for its endVals parameter (for when multiple properties are being tweened in one call), you need to use two sets of brackets to indicate that the color value is itself a nested Array.

The Fuse version also passes an Array but should only use one set of brackets because you're only declaring one property, which Fuse will send within an Array with any other properties in the action.


Author:
Moses Gunesch

Version:
0.2


Field Summary

public static
BLOCKINDENT: String
Tweens a TextField's block indent (TextFormat.blockIndent)

public static
INDENT: String
Tweens a TextField's first-line indent (TextFormat.indent)

public static
KERNING: String
Tweens a TextField's horizontal spacing between letters (TextFormat.letterSpacing)

public static
LEADING: String
Tweens a TextField's vertical spacing between lines (TextFormat.leading)

public static
LEFTMARGIN: String
Tweens a TextField's left margin (TextFormat.leftMargin)

public static
RIGHTMARGIN: String
Tweens a TextField's right margin (TextFormat.rightMargin)

public static
TEXT_COLOR: String
This property requires special array usage...

public static
TEXT_SIZE: String
Tweens a TextField's font size (TextFormat.size)

Method Summary

public
addTween ( target: Object, prop: String, endval: Object ): Boolean
Required by IFuseFX for compliance with FuseFX. Setup, called just prior to tweening.

public
defineProperties ( ): Array
Required by IFuseFX for compliance with FuseFX.

public
destroy ( target: Object ): Void
Required by IFuseFX for compliance with FuseFX. Cleanup, called just prior to deletion. Listeners are removed by FuseFX.

public
onTweenUpdate ( o: Object ): Void
Required by IFuseFX for compliance with FuseFX. Standard event fired by the engine on its update pulse just after updating the property.



Field Documentation

BLOCKINDENT

public static var BLOCKINDENT: String = "textBlockIndentFX"
Tweens a TextField's block indent (TextFormat.blockIndent)

INDENT

public static var INDENT: String = "textIndentFX"
Tweens a TextField's first-line indent (TextFormat.indent)

KERNING

public static var KERNING: String = "textKerningFX"
Tweens a TextField's horizontal spacing between letters (TextFormat.letterSpacing)

Usage:
The terminology differs here from TextFormat which contains a boolean kerning property for auto-kern and uses letterSpacing for numerical kern.

LEADING

public static var LEADING: String = "textLeadingFX"
Tweens a TextField's vertical spacing between lines (TextFormat.leading)

LEFTMARGIN

public static var LEFTMARGIN: String = "textLMarginFX"
Tweens a TextField's left margin (TextFormat.leftMargin)

RIGHTMARGIN

public static var RIGHTMARGIN: String = "textRMarginFX"
Tweens a TextField's right margin (TextFormat.rightMargin)

TEXT_COLOR

public static var TEXT_COLOR: String = "textColorsArrayFX"
This property requires special array usage...

Usage:
To tween a hex value in Fuse Kit you need to specify a colors array. The string value of this property reflects this, and it is the string "colors" appearing in the variable name (plus using an Array as the value) that forces this behavior in the engine. See ZigoEngine and Fuse docs for colors array info.

(Repeated from header:)
ZigoEngine.doTween(myTextField, TextFormatTween.TEXT_COLOR, [[0x33FF00]], 1, "easeInQuad");
 
// The same thing in Fuse would read:
myFuse.push({ target:myTextField, textColorsArrayFX:[0x33FF00], time:1, ease:"easeInQuad"});
					
Note that because doTween accepts an Array for its endVals parameter (for when multiple properties are being tweened in one call), you need to use two sets of brackets to indicate that the color value is itself a nested Array.

The Fuse version also passes an Array but should only use one set of brackets because you're only declaring one property, which Fuse will send within an Array with any other properties in the action.

TEXT_SIZE

public static var TEXT_SIZE: String= "textSizeFX"
Tweens a TextField's font size (TextFormat.size)


Method Documentation

addTween

public function addTween(target: Object,
 prop: String,
 endval: Object): Boolean
Required by IFuseFX for compliance with FuseFX. Setup, called just prior to tweening.

Specified by:

Parameters:
target
The tween target object (not necessary to store a hard reference!)
prop
The tween property which has been pre-verified as one of this extension's keys.
endval
The tween end-value passed by the user (for special cases like type checking)

defineProperties

public function defineProperties(): Array
Required by IFuseFX for compliance with FuseFX.

Specified by:

Returns:
An Array of FXProperty instances.

destroy

public function destroy(target: Object): Void
Required by IFuseFX for compliance with FuseFX. Cleanup, called just prior to deletion. Listeners are removed by FuseFX.

Specified by:

Parameters:
target
The original tween target, which may be missing. Passed to enable extensions to avoid storing a hard reference to tween targets.

onTweenUpdate

public function onTweenUpdate(o: Object): Void
Required by IFuseFX for compliance with FuseFX. Standard event fired by the engine on its update pulse just after updating the property.

Specified by:

Parameters:
o
Event object sent by engine containing {target:Object, props:Array}

The documentation was generated from the following file: