Renamed ControllerEvent to CommandEvent.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4281 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-07-20 02:14:14 +00:00
parent 19219bb1a3
commit f1f6b3bdb2
5 changed files with 33 additions and 17 deletions
+23 -5
View File
@@ -2,7 +2,7 @@ package com.threerings.util {
import flash.events.IEventDispatcher;
import com.threerings.events.ControllerEvent;
import com.threerings.mx.events.CommandEvent;
public class Controller
{
@@ -13,12 +13,12 @@ public class Controller
{
if (_panel != null) {
_panel.removeEventListener(
ControllerEvent.TYPE, handleControllerEvent);
CommandEvent.TYPE, handleCommandEvent);
}
_panel = panel;
if (_panel != null) {
_panel.addEventListener(
ControllerEvent.TYPE, handleControllerEvent);
CommandEvent.TYPE, handleCommandEvent);
}
}
@@ -32,7 +32,25 @@ public class Controller
*/
public function handleAction (cmd :String, arg :Object) :Boolean
{
// TODO: This warning should really be inside the ControllerEvent
// fall back to a method named the cmd
try {
var fn :Function = (this["handle" + cmd] as Function);
if (fn != null) {
try {
fn(arg);
} catch (e :Error) {
Log.getLog(this).warning("Error handling controller " +
"command [error=" + e + ", cmd=" + cmd +
", arg=" + arg + "].");
}
// we "handled" the event, even if it threw an error
return true;
}
} catch (e :Error) {
// suppress, and fall through
}
// TODO: This warning should really be inside the CommandEvent
// somewhere, and only generated if the event never gets cancelled
Log.getLog(this).warning("Unhandled controller command " +
"[cmd=" + cmd + ", arg=" + arg + "].");
@@ -43,7 +61,7 @@ public class Controller
* Private function to handle the controller event and call
* handleAction.
*/
private function handleControllerEvent (event :ControllerEvent) :void
private function handleCommandEvent (event :CommandEvent) :void
{
if (handleAction(event.command, event.arg)) {
// if we handle the event, stop it from moving outward to another