Conditional Debugging in Flash Builder 4

On August 15, 2010, in Flex Builder, Flex, by Anuj Gakhar

I have started using Flash Builder 4 recently and the one feature I am loving the most is the Conditional Debugging. Using conditional breakpoints in Flash Builder 4, you can configure a breakpoint to trigger only after a certain number of loop iterations. For instance, you can halt the application on the third time a breakpoint is reached. You can also use a conditional breakpoint to suspend the application when a particular expression either changes or evaluates to true. In the next walkthrough you will make the breakpoint that was set up in the first walkthrough conditional by adding an expression.

Consider the following piece of code :-

private function init():void
for (var i:int = 0;i < 15; i++)
var obj:Object = {label:’Label’ + i, data:i, selected:false};
ds.addItem( obj );

This code is simply creating 15 Objects and putting them all in an ArrayCollection for later use. If I want the debugger to break only when the loop is on its 10th run, then we can setup a conditional breakpoint that would look like this :-

You can open this Breakpoint Properties screen by right clicking on the actual BreakPoint and clicking on ‘BreakPoint Properties’. Notice I have Enabled a Condition (i == 10) which would make the debugger stop only when i is 10.

There is another option called “Hit Count” as you can see in the screenshot above. I can achieve the above scenario by using the Hit count feature as well, in which case, the Breakpoint Properties will look like this :-

In this case, the debugger only breaks when this particular breakpoint has been hit 10 times. As you can see, these are really useful features for a developer. I cant even begin to think of developing Flex apps without using the debugger. And these new features simply make this a lot more easier and useful.

Tagged with:  

5 Responses to Conditional Debugging in Flash Builder 4

  1. Simon Harris says:

    Conditional breakpoints have been a feature of debuggers in mainstream IDEs since at least the 1980s.

    • Jack says:

      Oh, Simon! Thank you so, SO much for that insight. I stumbled across this page and became aware of a new feature in FB, and I was beginning to think, “hey, cool…”. But now that I realize other things have conditional debugging, I now realize that this tip is lame, and that you are incredibly more knowledgeable.

      I applaud your vast computing experience and I thank you for what you’ve added to the web today! Congratulations — you must be so proud!

  2. I would also like to thank Simon. I thought this stuff was cool in the beginning — but it is not. Really! 😀

  3. Helly Wapple says:

    I am curious different code of software for this could be helpful on fixing some problem or even explore much on the field of IT. Good the you shared such an important code on debugging system. I’d like to know it well. Thanks!

  4. Anna says:

    Haha, this is very cool. I didnt know this was possible to do with flash!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2011 Anuj Gakhar