Some fixups. I think I'm going to want to refactor this so

that there are util methods for creating nice textfields, and then
generic animation classes for floating anything. This can then become
a convenience class that marries the two.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@207 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2007-04-24 22:55:29 +00:00
parent 476334e5ee
commit 03e3b1b91c
@@ -2,6 +2,8 @@ package com.threerings.flash {
import flash.events.Event; import flash.events.Event;
import flash.filters.GlowFilter;
import flash.text.TextField; import flash.text.TextField;
import flash.text.TextFieldAutoSize; import flash.text.TextFieldAutoSize;
import flash.text.TextFormat; import flash.text.TextFormat;
@@ -10,12 +12,16 @@ public class FloatingTextAnimation extends TextField
{ {
public static function create ( public static function create (
text :String, duration :Number = 1000, dy :int = -10, text :String, duration :Number = 1000, dy :int = -10,
format :TextFormat = null) :FloatingTextAnimation size :int = 18, font :String = "Arial", bold :Boolean = true,
color :uint = 0x000000, borderColor :uint = 0xFFFFFF) :FloatingTextAnimation
{ {
var fta :FloatingTextAnimation = new FloatingTextAnimation(); var fta :FloatingTextAnimation = new FloatingTextAnimation();
if (format != null) { var format :TextFormat = new TextFormat();
fta.defaultTextFormat = format; format.size = size;
} format.font = font;
format.bold = bold;
format.color = color;
fta.defaultTextFormat = format;
fta.autoSize = TextFieldAutoSize.CENTER; fta.autoSize = TextFieldAutoSize.CENTER;
fta.text = text; fta.text = text;
fta.width = fta.textWidth + 5; fta.width = fta.textWidth + 5;
@@ -23,6 +29,9 @@ public class FloatingTextAnimation extends TextField
fta.duration = duration; fta.duration = duration;
fta.dy = dy; fta.dy = dy;
fta.filters = [ new GlowFilter(borderColor, 1, 2, 2, 255) ];
return fta; return fta;
} }
@@ -45,8 +54,7 @@ public class FloatingTextAnimation extends TextField
override public function set y (val :Number) :void override public function set y (val :Number) :void
{ {
_startY = val; super.y = _startY = (val - height/2);
super.y = (val - height/2);
} }
protected function enterFrame (elapsed :Number) :void protected function enterFrame (elapsed :Number) :void
@@ -58,7 +66,7 @@ public class FloatingTextAnimation extends TextField
} }
alpha = 1 - perc; alpha = 1 - perc;
this.y = _startY + (dy * perc); super.y = _startY + (dy * perc);
} }
protected function handleAdded (... ignored) :void protected function handleAdded (... ignored) :void