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;