Use TextFieldUtil.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@214 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.threerings.flash {
|
||||
|
||||
import flash.display.Sprite;
|
||||
|
||||
import flash.events.Event;
|
||||
|
||||
import flash.filters.GlowFilter;
|
||||
@@ -8,9 +10,10 @@ import flash.text.TextField;
|
||||
import flash.text.TextFieldAutoSize;
|
||||
import flash.text.TextFormat;
|
||||
|
||||
public class FloatingTextAnimation extends TextField
|
||||
public class FloatingTextAnimation extends Sprite
|
||||
implements Animation
|
||||
{
|
||||
/*
|
||||
public static function create (
|
||||
text :String, duration :Number = 1000, dy :int = -10,
|
||||
size :int = 18, font :String = "Arial", bold :Boolean = true,
|
||||
@@ -35,24 +38,29 @@ public class FloatingTextAnimation extends TextField
|
||||
|
||||
return fta;
|
||||
}
|
||||
*/
|
||||
|
||||
public var duration :Number;
|
||||
|
||||
public var dy :Number;
|
||||
|
||||
public function FloatingTextAnimation ()
|
||||
public function FloatingTextAnimation (
|
||||
text :String, textArgs :Object = null, duration :Number = 1000, dy :int = -10)
|
||||
{
|
||||
AnimationManager.addDisplayAnimation(this);
|
||||
}
|
||||
var tf :TextField = TextFieldUtil.createField(text, textArgs);
|
||||
tf.x = -(tf.width/2)
|
||||
tf.y = -(tf.height/2);
|
||||
addChild(tf);
|
||||
|
||||
override public function set x (val :Number) :void
|
||||
{
|
||||
super.x = (val - width/2);
|
||||
this.duration = duration;
|
||||
this.dy = dy;
|
||||
|
||||
AnimationManager.addDisplayAnimation(this);
|
||||
}
|
||||
|
||||
override public function set y (val :Number) :void
|
||||
{
|
||||
super.y = _startY = (val - height/2);
|
||||
super.y = _startY = val;
|
||||
}
|
||||
|
||||
// from Animation
|
||||
|
||||
@@ -4,9 +4,9 @@ import flash.text.TextFormat;
|
||||
|
||||
public class SiningTextAnimation extends TextCharAnimation
|
||||
{
|
||||
public function SiningTextAnimation (text :String, format :TextFormat)
|
||||
public function SiningTextAnimation (text :String, textArgs :Object)
|
||||
{
|
||||
super(text, movementFn, format);
|
||||
super(text, movementFn, textArgs);
|
||||
}
|
||||
|
||||
protected function movementFn (elapsed :Number, index :Number) :Number
|
||||
|
||||
@@ -13,7 +13,7 @@ import flash.utils.getTimer; // function import
|
||||
public class TextCharAnimation extends Sprite
|
||||
implements Animation
|
||||
{
|
||||
public function TextCharAnimation (text :String, fn :Function, format :TextFormat)
|
||||
public function TextCharAnimation (text :String, fn :Function, textArgs :Object)
|
||||
{
|
||||
_fn = fn;
|
||||
|
||||
@@ -23,11 +23,7 @@ public class TextCharAnimation extends Sprite
|
||||
var h :Number = 0;
|
||||
var tf :TextField;
|
||||
for (var ii :int = 0; ii < text.length; ii++) {
|
||||
tf = createTextField(format);
|
||||
tf.autoSize = TextFieldAutoSize.CENTER;
|
||||
tf.text = text.charAt(ii);
|
||||
tf.width = tf.textWidth + 5;
|
||||
tf.height = tf.textHeight + 5;
|
||||
tf = TextFieldUtil.createField(text.charAt(ii), textArgs);
|
||||
|
||||
tf.x = w;
|
||||
w += tf.width;
|
||||
@@ -52,15 +48,6 @@ public class TextCharAnimation extends Sprite
|
||||
}
|
||||
}
|
||||
|
||||
protected function createTextField (format :TextFormat) :TextField
|
||||
{
|
||||
var tf :TextField = new TextField();
|
||||
tf.defaultTextFormat = format;
|
||||
return tf;
|
||||
}
|
||||
|
||||
protected var _startStamp :Number;
|
||||
|
||||
protected var _texts :Array = [];
|
||||
|
||||
protected var _fn :Function;
|
||||
|
||||
Reference in New Issue
Block a user