Last active
August 29, 2015 14:27
-
-
Save xavierstampslafont/3e29464c29e53124e4da to your computer and use it in GitHub Desktop.
OpenFL TextField border bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import openfl.display.Sprite; | |
import openfl.events.TimerEvent; | |
import openfl.text.Font; | |
import openfl.text.TextField; | |
import openfl.text.TextFormat; | |
import openfl.utils.Timer; | |
class Main extends Sprite { | |
private var _format:TextFormat; | |
private var _textField:TextField; | |
private var _timer:Timer; | |
public function new () { | |
super (); | |
graphics.beginFill(0x0); | |
graphics.drawRect(0, 0, 800, 800); | |
graphics.endFill(); | |
_format = new TextFormat ("Katamotz Ikasi", 30, 0x7A0026); | |
_textField = new TextField (); | |
_textField.defaultTextFormat = _format; | |
_textField.embedFonts = true; | |
_textField.selectable = false; | |
_textField.background = true; | |
_textField.backgroundColor = 0x0; | |
_textField.x = 50; | |
_textField.y = 50; | |
_textField.width = 200; | |
_textField.text = "Hello World"; | |
addChild (_textField); | |
_timer = new Timer(200); | |
_timer.addEventListener(TimerEvent.TIMER, changeTextColor); | |
_timer.start(); | |
} | |
private function changeTextColor(event:TimerEvent):Void { | |
var color:UInt = 0xFFFFFF; | |
if (_timer.currentCount % 2 == 0) { | |
color = 0x7A0026; | |
} | |
_format.color = color; | |
// The below lines cause the buggy behavior | |
// Either of them causes the issue | |
// Comment them in/out to reproduce | |
_textField.defaultTextFormat = _format; | |
_textField.setTextFormat(_format); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment