From db23c89ec0d85d96a68f8aae894aee27adf30645 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 21 Nov 2007 19:47:32 +0000 Subject: [PATCH] Don't use parentChanged() to track whether we're onscreen or not, it's unreliable. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@352 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flex/ChatControl.as | 44 ++++++++++++----------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/as/com/threerings/flex/ChatControl.as b/src/as/com/threerings/flex/ChatControl.as index a43fd3f3..2f0f1668 100644 --- a/src/as/com/threerings/flex/ChatControl.as +++ b/src/as/com/threerings/flex/ChatControl.as @@ -68,6 +68,9 @@ public class ChatControl extends HBox _txt.height = height; _but.height = height; } + + addEventListener(Event.ADDED_TO_STAGE, handleAddRemove); + addEventListener(Event.REMOVED_FROM_STAGE, handleAddRemove); } /** @@ -104,26 +107,6 @@ public class ChatControl extends HBox _txt.setStyle("backgroundColor", color); } - override public function parentChanged (p :DisplayObjectContainer) :void - { - super.parentChanged(p); - - if (p != null) { - // set up any already-configured text - _txt.text = _curLine; - - // request focus - callLater(function () :void { - _txt.setFocus(); - }); - _controls.push(this); - - } else { - _curLine = _txt.text; - ArrayUtil.removeAll(_controls, this); - } - } - /** * Handles FlexEvent.ENTER and the action from the send button. */ @@ -144,6 +127,27 @@ public class ChatControl extends HBox _txt.text = ""; } + /** + * Handles Event.ADDED_TO_STAGE and Event.REMOVED_FROM_STAGE. + */ + protected function handleAddRemove (event :Event) :void + { + if (event.type == Event.ADDED_TO_STAGE) { + // set up any already-configured text + _txt.text = _curLine; + + // request focus + callLater(function () :void { + _txt.setFocus(); + }); + _controls.push(this); + + } else { + _curLine = _txt.text; + ArrayUtil.removeAll(_controls, this); + } + } + /** Our client-side context. */ protected var _ctx :CrowdContext;