Moved here.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@126 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2007-01-31 02:59:09 +00:00
parent 12f8cabd90
commit 76074998f4
8 changed files with 908 additions and 0 deletions
@@ -0,0 +1,54 @@
package com.threerings.flex {
import flash.events.MouseEvent;
import mx.controls.Button;
/**
* A command button simply dispatches a Controller command (with an optional
* argument) when it is clicked.
*/
public class CommandButton extends Button
{
/**
* Create a command button.
*/
public function CommandButton (cmd :String = null, arg :Object = null)
{
setCommand(cmd, arg);
}
/**
* Set the command and argument to be issued when this button is pressed.
*/
public function setCommand (cmd :String, arg :Object = null) :void
{
_cmd = cmd;
_arg = arg;
}
override protected function clickHandler (event :MouseEvent) :void
{
super.clickHandler(event);
if (enabled) {
// stop the click event
event.stopImmediatePropagation();
// dispatch the command event
// if the arg is null and we're a toggle button, dispatch our state
var arg :Object = _arg;
if (arg == null && toggle) {
arg = selected;
}
CommandEvent.dispatch(this, _cmd, arg);
}
}
/** The command to submit when clicked. */
protected var _cmd :String;
/** The argument that accompanies our command. */
protected var _arg :Object;
}
}