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();