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 {
|
package com.threerings.flash {
|
||||||
|
|
||||||
|
import flash.display.Sprite;
|
||||||
|
|
||||||
import flash.events.Event;
|
import flash.events.Event;
|
||||||
|
|
||||||
import flash.filters.GlowFilter;
|
import flash.filters.GlowFilter;
|
||||||
@@ -8,9 +10,10 @@ import flash.text.TextField;
|
|||||||
import flash.text.TextFieldAutoSize;
|
import flash.text.TextFieldAutoSize;
|
||||||
import flash.text.TextFormat;
|
import flash.text.TextFormat;
|
||||||
|
|
||||||
public class FloatingTextAnimation extends TextField
|
public class FloatingTextAnimation extends Sprite
|
||||||
implements Animation
|
implements Animation
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
public static function create (
|
public static function create (
|
||||||
text :String, duration :Number = 1000, dy :int = -10,
|
text :String, duration :Number = 1000, dy :int = -10,
|
||||||
size :int = 18, font :String = "Arial", bold :Boolean = true,
|
size :int = 18, font :String = "Arial", bold :Boolean = true,
|
||||||
@@ -35,24 +38,29 @@ public class FloatingTextAnimation extends TextField
|
|||||||
|
|
||||||
return fta;
|
return fta;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public var duration :Number;
|
public var duration :Number;
|
||||||
|
|
||||||
public var dy :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
|
this.duration = duration;
|
||||||
{
|
this.dy = dy;
|
||||||
super.x = (val - width/2);
|
|
||||||
|
AnimationManager.addDisplayAnimation(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function set y (val :Number) :void
|
override public function set y (val :Number) :void
|
||||||
{
|
{
|
||||||
super.y = _startY = (val - height/2);
|
super.y = _startY = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from Animation
|
// from Animation
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import flash.text.TextFormat;
|
|||||||
|
|
||||||
public class SiningTextAnimation extends TextCharAnimation
|
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
|
protected function movementFn (elapsed :Number, index :Number) :Number
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import flash.utils.getTimer; // function import
|
|||||||
public class TextCharAnimation extends Sprite
|
public class TextCharAnimation extends Sprite
|
||||||
implements Animation
|
implements Animation
|
||||||
{
|
{
|
||||||
public function TextCharAnimation (text :String, fn :Function, format :TextFormat)
|
public function TextCharAnimation (text :String, fn :Function, textArgs :Object)
|
||||||
{
|
{
|
||||||
_fn = fn;
|
_fn = fn;
|
||||||
|
|
||||||
@@ -23,11 +23,7 @@ public class TextCharAnimation extends Sprite
|
|||||||
var h :Number = 0;
|
var h :Number = 0;
|
||||||
var tf :TextField;
|
var tf :TextField;
|
||||||
for (var ii :int = 0; ii < text.length; ii++) {
|
for (var ii :int = 0; ii < text.length; ii++) {
|
||||||
tf = createTextField(format);
|
tf = TextFieldUtil.createField(text.charAt(ii), textArgs);
|
||||||
tf.autoSize = TextFieldAutoSize.CENTER;
|
|
||||||
tf.text = text.charAt(ii);
|
|
||||||
tf.width = tf.textWidth + 5;
|
|
||||||
tf.height = tf.textHeight + 5;
|
|
||||||
|
|
||||||
tf.x = w;
|
tf.x = w;
|
||||||
w += tf.width;
|
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 _texts :Array = [];
|
||||||
|
|
||||||
protected var _fn :Function;
|
protected var _fn :Function;
|
||||||
|
|||||||
Reference in New Issue
Block a user