| By Dustin DuPree | Article Rating: |
|
| January 28, 2006 03:45 PM EST | Reads: |
22,969 |
As with almost any program you work with, there are going to be things you wish you could change, add, improve, or remove. It might be a feature you are used to from another program, or one you have devised on your own. "If only I could run to the developers and tell them my great idea, the program would be perfect," you say. I've often wanted to change things in my favorite software but am usually stuck waiting and hoping it will be fixed in the next version.
Thankfully, sometimes there are alternatives. Extending Fireworks enables you to create new features, tweaks, and modifications. They can be as simple as setting a few preferences or as complex as being an entirely separate application. There are several ways to extend Fireworks but they all work towards the same goal: extending the capabilities of Fireworks and making it work the way you want it to.
This article is intended for someone with an interest in making commands for Fireworks. It is a guide to help anyone who has even a small amount of programming knowledge to learn the procedure for creating commands. The first part of the article explains what commands are, where they are stored, and the different ways you can execute them. It also explains some of the basic concepts and structures of most Fireworks commands. The middle part examines a practical command example and discusses where to look for more help. The last section provides some advice for troubleshooting your commands as well as some information about packaging and distributing them. After completing this article you should have a good idea of what is possible with Fireworks commands and have an understanding of how to create and package them.
Getting Started with Your First Command
The fastest and simplest way to extend Fireworks is by creating commands. These are JavaScript files that give you control over the internal functions of Fireworks, extending the capabilities of the program to suit your needs. You control Fireworks by calling a set of custom JavaScript functions from within your commands using the Fireworks Application Programming Interface (API). Commands work by utilizing the Fireworks API to control the functionality of the program. They tap into all Fireworks tools and features and allow you to control them through code. View the Fireworks 8 API documentation to get a more complete overview of the Fireworks Object Model and the custom JavaScript functions that are built into Fireworks.
Now that you have a basic understanding of what commands are and how they work, it's time to get started making some of your own.
Hello World
The first command you make will simply create a dialog box in Fireworks that says "Hello World!" If you are familiar with JavaScript, then the alert() function is nothing new to you, but you will still learn where to store your custom commands and how to run them. First open Fireworks and create a new document, approximately 500 pixels wide and 400 pixels tall.
Create a new text file in your text editor of choice. Place this Fireworks command in it:
alert("Hello World!");
That's it! Now save the command and you're done.
Saving Your Commands
There are a couple options available for saving a command. If you are on a single-user machine or want everyone who uses your computer in a multiuser environment to be able to access the command, save it into your installation folder's Configuration\Commands subfolder:
(Windows) C:\Program Files\Macromedia\Fireworks 8\Configuration\Commands
(Mac OS) Macintosh HD:Applications:Macromedia:Fireworks 8:Configuration:Commands
If you want to limit access to just to your user name, save it here:
(Windows) C:\Documents and Settings\
<User Name>\Application Data\Macromedia\Fireworks 8\Commands
(Mac OS) Macintosh HD:Users:<User>:
Library:Application Support:Macromedia:Fireworks 8:Commands
Save the file as Hello World.jsf.
Testing Your Commands
After your command is saved, switch to Fireworks to test it. If you go to the Commands pop-up menu, there should be a new entry for the "Hello World" command you just saved. Click on it now to run the command. If you see a message box that says "Hello World!" then the command ran successfully. If you see a message box that says "Can not run the script. An error occurred." that means there is a problem with the script and you should switch back to your text editor and make sure you wrote the code correctly.
There are a couple of other options available for running commands in Fireworks:
- You can drag and drop .jsf files into Fireworks to run them; just make sure you drop them anywhere except the active document workspace.
- In Windows you can run commands by setting .jsf files to open with Fireworks (assuming they aren't already set by default). Right-click the "Hello World.jsf" file in the Fireworks 8\Configuration\Commands folder and select Open With from the context menu. A dialog box should open, showing Fireworks as the recommended application. If not, click the Browse button to find Fireworks.exe in your installation folder (usually it's C:\Program Files\Macromedia\Fireworks 8). Make sure to select the option that says "Always use the selected program to open this kind of file." Now simply double-click "Hello World.jsf" to run it on the active Fireworks document.
Hello World wasn't all that much fun but at least now you know how to create, save, and run a command. This time let's utilize some more interesting functions in the Fireworks API to make a simple command that contains more Fireworks-specific code.
Hello Universe
Make a new document in your text editor and save it to the commands folder as "Hello Universe.jsf". Copy the following command code:
var dom = fw.getDocumentDOM();
dom.addNewRectangle({left:10, top:10, right: 150, bottom: 45}, .25);
fw.selection[0].pathAttributes.fillColor = "#FF0000";
var stored_selection = new Array(); stored_selection.push(fw.selection[0]);
dom.addNewText({left:25, top:20, right: 140, bottom: 30}, false);
var tr = fw.selection[0].textRuns; tr.textRuns =
[{changedAttrs: {fillColor:"#FFFFFF", size: "16pt"},
characters: "Hello Universe!"}];
fw.selection[0].textRuns = tr;
stored_selection.push(fw.selection[0]);
fw.selection = stored_selection;
dom.group();
The first line of code uses the getDocumentDOM() method of the fw object. You can think of the fw object as a code representation of the Fireworks application itself. It contains the functionality and methods for the common tasks that Fireworks performs, such as Save Document, Save As, Export, and even Quit. The getDocumentDOM() method returns the Document Object Model (DOM) for the active document.
The document's DOM is stored into the dom variable to be used later in the command. The document's DOM can be thought of as a code representation of the active document in Fireworks. Any action you would perform on a document in Fireworks is handled by methods of the document's DOM, such as creating a rectangle, adding a text object, and arranging layers.
Published January 28, 2006 Reads 22,969
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Dustin DuPree
Dustin DuPree currently attends Milwaukee Area Technical College in Milwaukee, WI, studying visual communications/multimedia. He also freelances as a web developer and designer. His interests include Flash, Fireworks, programming, design, photography, playing guitar, computer gaming, film, politics, and reading. www.dujodu.com.
![]() |
Steven Grosvenor 02/08/06 05:11:34 AM EST | |||
Great article!, a little upset you forgot to mention me :-) I wrote Twist and Fade that shipped with Fireworks 8 through MX 2004, loads of commerical and free fireworks extensions and the first Macromedia DevNet articles on creating custom flash panels and extending Fireworks MX. Free extensions can be found here |
||||
![]() |
SYS-CON Italy News Desk 01/28/06 04:56:34 PM EST | |||
As with almost any program you work with, there are going to be things you wish you could change, add, improve, or remove. It might be a feature you are used to from another program, or one you have devised on your own. 'If only I could run to the developers and tell them my great idea, the program would be perfect,' you say. I've often wanted to change things in my favorite software but am usually stuck waiting and hoping it will be fixed in the next version. |
||||
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Ph.D. in Twitter Anyone?
- Eolas Sues the Internet
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Special Report on the Emerging Cloud Computing Trend
- Adobe Cans Another 9% of its Workforce
- My Thoughts on Ulitzer
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Ulitzer Live! New Media Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Executives Feature on Cloud Computing Expo Power Panel
- Software Flexibility in the Cloud - Part 4 of 5
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Where Are RIA Technologies Headed in 2008?
- Cover Story: How to Increase the Frame Rates of Your Flash Movies
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Your First Adobe Flex Application with a ColdFusion Backend
- Adobe Flex 2: Advanced DataGrid
- i-Technology Blog: Death-Knell For "Rich Media? Hardly!
- Adobe/Macromedia - Microsoft, Look Out!
- How To Create a Photo Slide Show ...
- Adobe Flex Interface Customization - Themes, Styles, Skins
- Personal Branding Checklist
- Has the Technology Bounceback Begun?
- "Real-World Flex" by Adobe's Christophe Coenraets





































