Made my CommandButton factory method the constructor.

I had initially been hesitant to do this because of the parameter that
can be one of two things, and the Java side of me wanted to hold
on to compile-time checking, but the convenience is too damn convenient.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@408 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2008-02-06 01:03:55 +00:00
parent 1fb449b30b
commit a6e1fbe468
3 changed files with 29 additions and 30 deletions
@@ -33,9 +33,24 @@ import com.threerings.util.CommandEvent;
*/
public class CommandLinkButton extends LinkButton
{
public function CommandLinkButton (cmd :String = null, arg :Object = null)
/**
* Create a command link button.
*
* @param label the label text for the button.
* @param cmdOrFn either a String, which will be the CommandEvent command to dispatch,
* or a function, which will be called when clicked.
* @param arg the argument for the CommentEvent or the function. If the arg is an Array
* then those parameters are used for calling the function.
*/
public function CommandLinkButton (label :String = null, cmdOrFn :* = null, arg :Object = null)
{
setCommand(cmd, arg);
if (cmdOrFn != null && !(cmdOrFn is String) && !(cmdOrFn is Function)) {
// runtime errors suck, but this is actionscript
throw new Error("cmdOrFn must be a String or Function.");
}
this.label = label;
_cmdOrFn = cmdOrFn;
_arg = arg;
}
/**