
200 Debug an Application
Set a breakpoint
To debug the problem, you can set a breakpoint on the line of code to suspend the application
so that you can inspect the function. Hitting a breakpoint activates the debugging perspective.
1. In the code editor, locate the line of code that contains the Button control. You’ll see that
the Button control’s Click event is bound to the
calculate function. Since this is where
the function is called, this is where you set the breakpoint.
2. Set a breakpoint on the line that contains the Click event handler by right-clicking
(Control-click on Macintosh) in the left margin of the code editor. Select Toggle
Breakpoint from the context menu and a breakpoint marker is added to the margin, as
shown here:
3. Save the file and you’re ready to debug the application.
NOTE
When setting breakpoints in MXML it’s important to understand that when you set a
breakpoint on a line it is set for all elements of the line. If you set a breakpoint on this
line and then run the application, the breakpoint will be activated as soon as the
Button control is drawn on the screen, rather than when it is clicked. To work around
this, you need to format your MXML to place a component’s attributes on separate
lines, as shown here:
<mx:Button
id="btn_calculate"
click="calculate();"
x="95"
y="140"
label="Calculate"
width="100"/>
Commentaires sur ces manuels