Debugging your Fireworks MX Flash Commands (Part II) The Art of Tracing
For quick down and dirty (yet still effective) debugging, you can use the timeless art of tracing variables staight out from the internal Flash player within Flash MX to the output window. This is often useful when you wish to check if a condition exists and report that value to the output window. You can also Pseudo Trace your movie if it is a Fireworks MX Flash Command within Fireworks MX as we shall see later.
Tracing within Flash MX
The following snippet of code illustrates a simple tracing example when a condition is met. When the condition is triggered, the value is sent to the output window for viewing.
if (val !== x+Math.Round((x*tempval))) {trace (“Traced Value: ” +val);} |
You can use tracing for whatever output you need to get feedback on, or whether a specific condition you specifiy is being met or not.
Pseudo Tracing within Fireworks MX
I call it Pseudo Tracing, however its really just a case of triggering alerts within Fireworks MX based on the same criteria as within Flash MX. The difference here being that an alert is thrown within Fireworks MX rather than it being outputted to an internal application window.
In exactly the same wasy as before within Flash MX, we can substitute the trace command with a Fireworks API call to get feedback within Fireworks MX when the command is exported.
if (val !== x+Math.Round((x*tempval))) {MMAlert(“Traced Value: ” +val);} |
After you are happy that your functions or commands are working properly, just comment the alert line out else it will thrown everytime the condition you have set is met, and you are ready to deploy your extension.
if (val !== x+Math.Round((x*tempval))) {//Execute your FunctionmyFunction();
//MMAlert(“Traced Value: ” +val); } |
Conclusion
Do not underestimate the power of tracing and alerting, they can and should be your bread and butter for quick and simple debugging and checking that your conditions and loops are working properly. Always make sure you also save your work after a major revision, or when you manage to get an important section of code to work, and make a backup just in case it becomes corrupted ( Paranoia?)