Flex Builder tip: How to dismiss the “Add Watch Expression” dialog from the keyboard

One add-watch-expressionof the most common Flex Builder debugger complaints is that when you bring up the dialog to add a new expression to the Expressions view (e.g. via right-click > Add Watch Expression), you cannot dismiss this dialog using the keyboard alone. The dialog has a multi-line edit box, and if you press Return, that just adds a carriage return to the edit box. Similarly, trying to tab out of the edit box doesn’t work — it just inserts a tab character into the edit box.

This drives keyboard-heavy users (like me) crazy. However, it turns out that there is a way to dismiss this dialog from the key:

Type Shift+Return instead of Return.

There is, in fact, a good reason why this dialog has a multi-line edit box. As explained in this Eclipse bug, some languages (including Java) allow you to enter more than just a simple expression into this box. And since the dialog comes from Eclipse’s code rather than from Flex Builder’s, we can’t just change it to have a single line.

Since this is such a common point of frustration for Flex Builder users, in the above-linked bug I have asked that they find some way to make this easier for people to deal with, e.g. by perhaps having a short message in the dialog mentioning Shift+Return. But in any case, you now know the secret handshake — enjoy!

AprilScript: ActionScript worst practices

In honor of the date, and in the spirit of the old Obfuscated C Code Contest, I’ve written a bit of code to demonstrate some of the more, shall we say, interesting things you can do with ActionScript.

The code:

package {
    import flash.display.*
    import flash.text.*

    public class AprilFools extends Sprite {
        エイプリルフール var Number = 4..toString()

        use namespace エイプリルフール

        function AprilFools()
        {
            get = set
            set = get

            with (createTextField())
                text = new Date(Number).toDateString()
        }

        function get get() { return Number + <><{Number}
            b={"/"+Number.split(/\//)[0]*502.25}/></>..@b }
        function set get(set) { Number = set+'/'+set/4 }

        function get set() { return Number }
        function set set(get) { Number = get }

        // nothing fun here
        function createTextField():TextField
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            var textField:TextField = new TextField();
            textField.width = 1000;
            addChild(textField);
            return textField;
        }
    }
}

namespace エイプリルフール

The program’s weak spot is creativity in terms of what it actually does — just some static text output. Pretty pathetic really. All my effort went into the ActionScript. Click here to see the result. It’s probably not worth the effort to try to figure out what it does before running it; that’s not really the fun part. The fun part is trying to figure out why the heck the thing compiles at all; what the individual lines of code actually mean; and what sick features of the language I am taking advantage of. Tell me what you find.

All Flex developers, please do this.

Even if you aren’t a Mac user, please do this to your Flex apps.

Even if you aren’t the kind of person who uses the scroll wheel on your mouse or two-finger scroll on your trackpad, please do it.

If you do, you will make some of your users very very happy.

Next Page »