From 03e3b1b91ca66cfc2a2152229cd367c3af35412e Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Tue, 24 Apr 2007 22:55:29 +0000 Subject: [PATCH] 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 --- .../threerings/flash/FloatingTextAnimation.as | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/as/com/threerings/flash/FloatingTextAnimation.as b/src/as/com/threerings/flash/FloatingTextAnimation.as index 06579650..a7f23230 100644 --- a/src/as/com/threerings/flash/FloatingTextAnimation.as +++ b/src/as/com/threerings/flash/FloatingTextAnimation.as @@ -2,6 +2,8 @@ package com.threerings.flash { import flash.events.Event; +import flash.filters.GlowFilter; + import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; @@ -10,12 +12,16 @@ public class FloatingTextAnimation extends TextField { public static function create ( 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(); - if (format != null) { - fta.defaultTextFormat = format; - } + var format :TextFormat = new TextFormat(); + format.size = size; + format.font = font; + format.bold = bold; + format.color = color; + fta.defaultTextFormat = format; fta.autoSize = TextFieldAutoSize.CENTER; fta.text = text; fta.width = fta.textWidth + 5; @@ -23,6 +29,9 @@ public class FloatingTextAnimation extends TextField fta.duration = duration; fta.dy = dy; + + fta.filters = [ new GlowFilter(borderColor, 1, 2, 2, 255) ]; + return fta; } @@ -45,8 +54,7 @@ public class FloatingTextAnimation extends TextField override public function set y (val :Number) :void { - _startY = val; - super.y = (val - height/2); + super.y = _startY = (val - height/2); } protected function enterFrame (elapsed :Number) :void @@ -58,7 +66,7 @@ public class FloatingTextAnimation extends TextField } alpha = 1 - perc; - this.y = _startY + (dy * perc); + super.y = _startY + (dy * perc); } protected function handleAdded (... ignored) :void