New Flex Builder debugger features: Conditional breakpoints, function calls from expressions, watchpoints, and more

I wanted to tell you all about some of the exciting debugger features we've been working on, which will be in Flex Builder 4, including several of the most common requests. All of the features listed below are in the preview release of Flex Builder that we gave out at MAX, with the, um, exception of exception breakpoints, which are not yet in the product. If you were at MAX, give these features a try, and let us know your feedback! If you weren't able to make it to MAX, don't worry, this stuff will eventually show up in a beta on Adobe Labs, and then of course in the final product as well.

Conditional breakpoints

Suppose you have set a breakpoint, but that line of code is reached hundreds of times, and you only care about the case where a variable 'x' is unexpectedly equal to null.  Just right-click on the breakpoint, go to its properties, and add the condition:

For some extra breakpointy goodness, you can also set a hit count on any breakpoint -- e.g. a hit count of 5 means, don't halt until the fifth time that line of code is reached.

Awesome new expression evaluator: function calls, E4X, regular expressions, etc.

Going along with conditional breakpoints is a vastly improved expression evaluator.  It is used when evaluating conditional breakpoints, in the Expressions view, and in debugger tooltips.

For one thing, you can now make function calls directly from the Expressions view (as well as from conditional breakpoints):

mystr.indexOf("test")


Also, regular expressions and E4X expressions can be quite tricky to debug; with the new expression evaluator, you can just type them into the Expressions view and immediately see the value.  (The one exception is you can't use E4X filter expressions such as "myxmlvar.(@id=='3')".)  For example, suppose "customers" is an XML object -- you can do expressions like these in the Expressions view:

myCustomersXML.customer.@name
myCustomersXML..zipCode
myCustomersXML.customer[0].@name


Here is a regular-expression example that you could put in the Expressions view or a breakpoint condition:

mystr.match( /[0-9]+/ig )


You can use the ternary ( ?: ) operator:

mystr.length>=3 ? mystr.charAt(2) : "too short"


You can use the "is" operator (this is especially useful in conditional breakpoints):

obj is String


The possibilities are limitless. ===, !==, string concatenation, etc. -- almost any other ActionScript expression you can think of, you can put it in the Expressions view or a breakpoint condition.

Watchpoints

Watchpoints tell the debugger to immediately halt when the value of a particular variable changes. Suppose you have a variable whose value keeps changing out from under you, and you can't figure out who is changing it. With a watchpoint, it's trivial -- just set the watchpoint and run your code.

(Flex Builder watchpoints are set on a particular instance of a variable. For example, you set a watchpoint on the _width field of a button "myButton", not on the _width field of all Buttons.)

Exception breakpoints

The debugger always halts immediately whenever there is an uncaught exception. But sometimes, you want the debugger to halt even on an exception that is going to be caught by a try/catch block in your code.

That's what exception breakpoints will let you do. You will be able to say, for example, "Always halt in the debugger whenever a TypeError is thrown, even if it is going to be caught."

Run to line

A minor feature but still quite nice to have: Run to Line (Cmd+R on Mac, Ctrl+R on Windows) is a quick way to set a temporary breakpoint on the current line, then run until you get there, and then automatically clear the temporary breakpoint.

Network monitor

A major addition, this allows you to easily see the network traffic that is going back and forth between your app's front end and its back end.

Click for a closer view:

MAX talk: Extending Flex Builder

I've been busily working on slides the the MAX talk that David Zuckerman and I are giving together, Extending Flex Builder. This will be an interesting session for people who want to extend Flex Builder with their own add-ons.

The topics we'll be covering are:

  • The Code Model.  David will give this portion of the talk. The Code Model is an API that lets you programmatically browse and modify the set of ActionScript classes, functions, etc. that are in the user's code.
  • The Design Model.  This is another API that lets you programmatically browse and modify the MXML portions of the user's code.
  • If you write your own SWC (Flex library project) and want to customize how it shows up in the Components view when you give the SWC to another user, and also how it appears in the Properties view when they have an instance of your component selected in design view, you can add a file called design.xml to your SWC.
  • If we have time, we'll also give a very brief introduction to writing Eclipse plug-ins, which is necessary if you are going to be using the Code Model and the Design Model.  Not sure if there will be time for this, because there is so much other stuff we're trying to squeeze in.
Hope to see you there!

Typing with one hand is hard :-(

About a week ago, the Flex team took the afternoon off to go to the park and play kickball. Yeah that's right, the game for little kids, like baseball except that you kick a big red rubber ball.

Wheeeeeee owwww. Catching a fly ball (at least I caught it), I jammed my finger. Turned out I fractured the fifth metacarpal bone in my hand, and will be wearing a brace and/or cast for four to six weeks.

This is making it ridiculously hard to type. I don't really want to take any time off work, because I just got back from a nice long sabbatical and am eager to get back to Flex Builder features. So I'm just going to keep plugging away, albeit a lot more slowly than usual.

Voice recognition software helps with email and the like, but not with coding. I even had another weird but creative idea that didn't quite pan out: one funny thing about this is that with the brace on my hand, it is actually easier to type on my iPhone than on a computer keyboard. (I am writing this blog post on the iPhone.) So, I installed VNC software on my computer, and then installed Mocha VNC Lite on my iPhone. That way, I can use the iPhone got typing on my computer!  But alas, when you do that, you don't get the iPhone's auto-correct capabilities, and without that, the iPhone was too tedious to type on.

Anyway, I am plugging away on lots of really cool debugger features for Flex Builder 4. I can't tell you what they are, but I just can't resist mentioning that our awesome summer intern, Sedat Akkus, has implemented one of the most-requested debugger features. So what is the feature?  Well, that's a secret, but it rhymes with "fronditional schmakepoints."

« Previous PageNext Page »