Debugging in FDT 3.0 Enterprise – a small tutorial
If you are familiar with debugging in Flex Builder, this will be very easy for you. In FDT it's nearly the same procedure.
First of all create your main entry class, here a class named "Test".
Before debugging you have to make sure that the debugging mode is on. So let's have a look at the compiler arguments:
Run > Open Debug Dialog > FDT AS3 Application > [Your project] > Compiler arguments
There you have to add -debug=true.
Of course you have to enter the main entry class and so on. It's not mentioned here because the tutorial focuses on debugging.
In the first case we just test two trace actions.
In the new enterprise version you can now set breakpoints by doubleclicking in the panel with the line numbers (here in line 9). (A contenxt menu entry is missing right now.)
A blue point icon will appear. After this we can start the debug session with Run > Debug as. You can also use the run buttons – right one, the bug:
Or of course the context menu:
After starting this, a prompt will appear the first time. Activate "Remember my decision" and click "Yes".
Eclipse now switched to the debug perspective.
You can see that the script stopped before the first trace.
To perform the first trace, click the "Step over" button (F6).
Now you can see the trace in the console on bottom. Step over again and the next trace is performed.
If you want to resume your application, you can use the green "Resume" arrow (or F8). If you have several breakpoints, the application will resume and pause at the next one.
Pretty cool: To inspect a problem, set there a breakpoint and see step for step what happens in your application.
Just try and play around.
To switch back to the editor mode use Window > Open perspective or have a look at the top right. Choose "Flash FDT".
This panel the best way to switch your perspectives fast.
I'm sure you noticed the variables inspector.
All properties are listed there (at the moment only the main timeline). So let's introduce a variable with some dummy action.
Start again the debugging session. This time the "step" variable is listed, too. It's undefined because the application stops before the action.
So again step over (F6) and you will see the variable changing to 0. After another step, it will be 1.
We could try that again and as expected the value would be 2.
But let's change the value to 5 in the inspector.
And then press the "Step over" button again. Now the value is 6!
This means: You can change primitive values by runtime. Cool, isn't it?
Of course the variables inspector is not only for primitive types. Play around and try to create a sprite for example.
Debug again and you will get a output in a similar manner to "this" (=root).
You can also define output templates for classes. For this you have to open the preferences.
Window > Preferences > FDT > Run/Debug > Reference types
E.g. Sprite is predefined in FDT, so let's have a look at the main timeline again.
In the bottom of the window you see your custom output for sprites.
If your perspective doesn't switch automatically, check the settings in:
Window > Preferences > Run/Debug > Perspectives
Set "Open the associated perspective when launching" to "Always".
Have also a look on:
Window > Preferences > Run/Debug > Launching
For example you can auto run the debug mode, if your script contains breakpoints and you start the normal "Run".
Author: Sebastian Weyrauch