From 0ac052bc9fefee4336633e397a4d6c192db2a542 Mon Sep 17 00:00:00 2001 From: Daniel Sperl Date: Thu, 16 Jan 2014 13:53:27 +0100 Subject: [PATCH] fixed missing textField-dispose in Button; fixed text alignment getters (refs #456) --- starling/src/starling/display/Button.as | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/starling/src/starling/display/Button.as b/starling/src/starling/display/Button.as index b706eb11a..33b13f0d6 100644 --- a/starling/src/starling/display/Button.as +++ b/starling/src/starling/display/Button.as @@ -79,6 +79,15 @@ package starling.display this.text = text; } + /** @inheritDoc */ + public override function dispose():void + { + // text field might be disconnected from parent, so we have to dispose it manually + mTextField.dispose(); + + super.dispose(); + } + private function resetContents():void { mIsDown = false; @@ -239,7 +248,11 @@ package starling.display } /** The vertical alignment of the text on the button. */ - public function get textVAlign():String { return mTextField.vAlign; } + public function get textVAlign():String + { + return mTextField ? mTextField.vAlign : VAlign.CENTER; + } + public function set textVAlign(value:String):void { createTextField(); @@ -247,7 +260,11 @@ package starling.display } /** The horizontal alignment of the text on the button. */ - public function get textHAlign():String { return mTextField.hAlign; } + public function get textHAlign():String + { + return mTextField ? mTextField.hAlign : HAlign.CENTER; + } + public function set textHAlign(value:String):void { createTextField();