|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Fireworks Creating Panels in Macromedia Fireworks
When it comes to designing and optimizing web graphics, it doesn't get much better than Macromedia Fireworks
By: Trevor McCauley
Feb. 10, 2006 11:15 AM
Keep a Fireworks JavaScript Reference Handy I suggest downloading the PDF version (ZIP, 1.2 MB) instead of the Help system. I find that searching within the PDF is more accurate than searching through Help. Plus you get to have every page open and easily accessible, unlike the segmented Help system. Be sure to keep up with the Fireworks 8 LiveDocs for any corrections and suggestions made by other Fireworks users.
Reuse Your Scripts
Publish Your Panel SWF Directly to the Command Panels Folder
Note: There are two ways to get rid of a panel in Fireworks: closing it and hiding it. When you reopen a panel, if it was hidden, it will not reload the SWF. The SWF is only reloaded if the panel is reopened after having been closed. To close a panel you must either right-click its title bar and select Close Panel Group or click the close button available to the panel when it's undocked. Hiding a panel happens when you reselect the panel name in the Windows menu when it is already opened. For undocked panels, hiding a panel in this manner makes it appear as though the panel were closed.
Test Incrementally
Debugging Fireworks Commands There's a two-step process involved when Fireworks receives a Fireworks JavaScript command. First it evaluates the script and then it executes the script. A problem can occur at either step - and either step can produce an error alert. Such alerts, however, will not always be invoked if the script is run from within a Flash panel - a reason why testing outside of the panels themselves can be beneficial. When Fireworks encounters a problem with evaluation, no script will be executed and an error will be immediately issued. This usually means there's been a syntax error such as mismatched brackets ( {} ) or a misuse of operators. There will be no indication of where the error occurs. It will be left up to you to find out where that is (see Figure 8). More advanced external script editors like Dreamweaver 8 should help you find such errors, thanks to features such as color coding. The following example will create an error in Fireworks due to an error in script evaluation:
function copy () { The problem with the above script is that the copy function block was not closed with an ending bracket ( } ). As a result, Fireworks kills the command and issues an error before anything even gets to be executed. Getting a script to evaluate correctly is half the battle. An error can still occur if there is a problem with execution. If that happens, Fireworks will issue an alert directly after reaching the problematic code. Problems in execution usually result from attempting to use a variable or function that does not exist or calling a native Fireworks method with incorrect arguments. The following example will create an error in Fireworks due to an error in script execution:
function copy () { Now the copy function is correctly defined here but when it is called at the bottom of the script, it's misspelled. Because the copie function doesn't actually exist, there is an error when Fireworks attempts to call it, which kills the script and issues the error alert. Although the error message for both the previous examples is the same ("Could not run the script. An error occurred."), there is a slight advantage in dealing with errors resulting from execution. That advantage is the simple fact that code prior to the faulty code is correctly executed before Fireworks issues the error. This allows you to find out at least how far a script has gone before reaching bad code, or even if it manages to execute any code at all. The most common indicator is a simple JavaScript alert. Consider the following script:
alert("Defining copy function"); When you run this script in Fireworks, you get three alert messages, "Defining copy function," "Calling copy function," and the inevitable error, "Could not run the script. An error occurred." The fact that "Defining copy function" is alerted tells you immediately that the script was evaluated correctly and that there are no errors with the syntax. Seeing "Calling copy function" tells you that copy was defined correctly and that it is about to be called within the script. Given that the error message is seen instead of the "Script Complete" alert indicates that there was something wrong with the call to the copy function. Upon closer inspection, the spelling error can be identified and corrected. The previously mentioned Command Prompt extension is a great way to help test scripts in Fireworks. Keep in mind, however, that because the Command Prompt extension is a custom SWF panel, it may fail to provide some Fireworks error alerts when it encounters a problem in the script. Including your own alerts when using the Command Prompt is nonetheless beneficial in determining whether a script is correctly interpreted or whether or not it is executed completely and successfully by Fireworks. Fireworks actually provides a means to help you debug SWF panels as they send the script to the application. It provides two Fireworks JavaScript methods - fw.enableFlashDebugging() and fw.disableFlashDebugging() - that let you turn debugging mode on and off for commands sent to Fireworks. Don't get too excited, though. All that this debugging includes is an alert of the script being sent to Fireworks from a call to MMExecute. Chances are that you, being the panel developer, already know what that script is so using these methods may only help so much. Calling fw.enableFlashDebugging turns on this alert feature, while fw.disableFlashDebugging turns it off. Here are some things to consider when debugging:
Now that you have a better understanding of debugging and improvements that can be made to your workflow, it's time to start with a new, slightly more complex example: the Mirror panel. Reader Feedback: Page 1 of 1
Your Feedback
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
||||||||||||||||||||||||||||||||||||||||||||||||||||