From 06f7f75fde54730c3fc3f480c1ba9e4b5950b115 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 31 Jan 2007 03:03:17 +0000 Subject: [PATCH] Moved CommandEvent back, update imports. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@127 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flex/CommandButton.as | 2 + src/as/com/threerings/flex/CommandEvent.as | 88 --------------------- src/as/com/threerings/flex/CommandMenu.as | 2 + 3 files changed, 4 insertions(+), 88 deletions(-) delete mode 100644 src/as/com/threerings/flex/CommandEvent.as diff --git a/src/as/com/threerings/flex/CommandButton.as b/src/as/com/threerings/flex/CommandButton.as index 373620b4..6ece1a64 100644 --- a/src/as/com/threerings/flex/CommandButton.as +++ b/src/as/com/threerings/flex/CommandButton.as @@ -4,6 +4,8 @@ import flash.events.MouseEvent; import mx.controls.Button; +import com.threerings.util.CommandEvent; + /** * A command button simply dispatches a Controller command (with an optional * argument) when it is clicked. diff --git a/src/as/com/threerings/flex/CommandEvent.as b/src/as/com/threerings/flex/CommandEvent.as deleted file mode 100644 index e00b723a..00000000 --- a/src/as/com/threerings/flex/CommandEvent.as +++ /dev/null @@ -1,88 +0,0 @@ -package com.threerings.flex { - -import flash.errors.IllegalOperationError; - -import flash.events.Event; -import flash.events.IEventDispatcher; - -public class CommandEvent extends Event -{ - /** The event type for all controller events. */ - public static const TYPE :String = "commandEvt"; - - /** - * Use this method to dispatch CommandEvents. - */ - public static function dispatch ( - disp :IEventDispatcher, cmd :String, arg :Object = null) :void - { - // Create the event - var event :CommandEvent = create(cmd, arg); - - // Dispatch it. A return value of true means that the event was - // never cancelled, so we complain. - if (disp == null || disp.dispatchEvent(event)) { - Log.getLog(CommandEvent).warning("Unhandled controller command " + - "[cmd=" + cmd + ", arg=" + arg + "]."); - } - } - - /** The command. */ - public var command :String; - - /** An optional argument. */ - public var arg :Object; - - /** - * Command events may not be directly constructed, use the dispatch - * method to do your work. - */ - public function CommandEvent (command :String, arg :Object) - { - super(TYPE, true, true); - if (_blockConstructor) { - throw new IllegalOperationError(); - } - this.command = command; - this.arg = arg; - } - - /** - * Mark this command as handled, stopping its propagation up the - * hierarchy. - */ - public function markAsHandled () :void - { - preventDefault(); - stopImmediatePropagation(); - } - - override public function clone () :Event - { - return create(command, arg); - } - - override public function toString () :String - { - return "CommandEvent[" + command + " (" + arg + ")]"; - } - - /** - * A factory method for privately creating command events. - */ - protected static function create (cmd :String, arg :Object) :CommandEvent - { - var event :CommandEvent; - _blockConstructor = false; - try { - event = new CommandEvent(cmd, arg); - } finally { - _blockConstructor = true; - } - return event; - } - - /** Used to prevent unauthorized construction. */ - protected static var _blockConstructor :Boolean = true; -} -} diff --git a/src/as/com/threerings/flex/CommandMenu.as b/src/as/com/threerings/flex/CommandMenu.as index 4aadeb48..6d2913ef 100644 --- a/src/as/com/threerings/flex/CommandMenu.as +++ b/src/as/com/threerings/flex/CommandMenu.as @@ -10,6 +10,8 @@ import mx.core.mx_internal; import mx.core.ScrollPolicy; import mx.events.MenuEvent; +import com.threerings.util.CommandEvent; + /** * A pretty standard menu that can submit CommandEvents if menu items * have "command" and possibly "arg" properties. Commands are submitted to