Archive for May, 2006

Quick fix!

David Zuckerman, also on the Flex Builder team, has written a totally awesome extension plugin for Flex Builder. It provides “Quick Fix” — with a quick keystroke or two, you can tell Flex Builder to automatically fix certain common errors and warnings. For example, say you wrote this:

function f()
{
    return "hello";
}

The compiler will warn you that function f() has no type. But, Ctrl-1, Quick Fix, and voilà — Flex Builder guesses that the return value of f() should be of type String:

function f():String
{
    return "hello";
}

Here’s a screenshot of QuickFix adding a type to a variable:

There is lots more. It is highly recommended.

How Flex Builder launches the Flash Player

In Flex Builder 2.0, when you click Debug or Run, Flex Builder launches the Flash Player.  But which Flash Player?

By default, it launches your system’s default web browser.  However, you can change that if you need to.

If you go to Window > Preferences, General, Web Browser, you will see a preference for which browser to use.  This preference controls which browser to use for everything in Eclipse, not just which browser to use for Flex Builder’s debugging.  For example, it controls which browser will be used if you double click on a .html file in the Navigator view.

But there is another option.  I often like to use the standalone Flash player (SAFlashPlayer.exe), because it launches a bit faster than the browser.  There are times when you really need your Flash app to be running “in context” inside an HTML page, such as when the Flash app and the JavaScript on the page are interacting with each other; but if that is not the case, then you might like debugging with the standalone Flash player.

Doing that is easy, although not obvious: Go to the Run > Debug… dialog, and change the launch URL so that it ends with “.swf” instead of “.html”.  For example, if the URL is C:\MyProject\MyProject-debug.html, change it to C:\MyProject\MyProject-debug.swf.

Note that this only works for local URLs.  HTTP and HTTPS URLs always cause a web browser to run, never the standalone Flash player.

Click for an example: Debug dialog

Killer Flex Builder 2.0 keyboard shortcuts

Flex Builder 2.0 has some really great ways to quickly navigate through your source code — e.g. “go to definition” and stuff like that. Most of these are based on similar features in Eclipse’s Java editing environment (the JDT).

Ctrl-O: Lightweight popup with list of functions in current file. Great for quick navigation within a file.

Ctrl-Shift-T: Open type. A quick way to go to the source for any class.

Ctrl-Click or F3: Go to definition. Ctrl-click on just about anything — function name, variable name, etc. — to go to its definition. F3 does the same thing.

Alt-Left, Alt-Right; or yellow arrows on toolbar: Back, Forward navigation, like in a web browser.

Ctrl-Shift-O: Organize imports — makes them alphabetical and tidy.

Ctrl-Space: Code hinting (of course).

Ctrl-Shift-Space: Restores tooltip showing the args of the function you are trying to call, e.g. if you have already written “foo(” but then moved somewhere else so the codehint had gone away

« Previous PageNext Page »