Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
Programmer's Guide to Fireworks Commands
Getting started with your first command

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.
Using the Fireworks API for Your Second Command
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.

About 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.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

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

http://www.phireworx.com/content/members/login.asp

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.


Your Feedback
Steven Grosvenor wrote: 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 http://www.phireworx.com/content/members/login.asp
SYS-CON Italy News Desk wrote: 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.
Latest Cloud Developer Stories
Can you bring services from the cloud to your customers faster and have them adopt it with ease of use or bring the power of bundled services to the fingertips of your clients without creating new rigid ‘apps stove pipes'? Do you want to prevent your business running away to publ...
OCZ Technology Group, a provider of high-performance solid-state drives (SSDs) for computing devices and systems, on Tuesday announced the Z-Drive R4 CloudServ PCI Express (PCIe) flash storage solution, designed to accelerate cloud computing applications and reduce operating expe...
Many organizations have embraced, or are considering, the benefits of cloud computing – speed, flexibility, increased expertise, shared workload, reduced costs, etc. The benefits are many – but so are the risks. What are the threats to cloud security? Which parties assume respons...
In August 2011, SHI Enterprise Solutions (ESS) division launched the SHI Cloud, offering reliable and cost-effective industrial-grade cloud computing platforms. That same division achieved an 82 percent increase in revenue over 2010.
SoftLayer Technologies on Tuesday announced the immediate worldwide availability of SoftLayer Object Storage, a redundant and highly scalable cloud storage service that allows users to easily store, search and retrieve data across the Internet, with optional CDN connectivity, or ...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers
ADS BY GOOGLE

Breaking Cloud Computing News
Salary increases will remain negligible in Japan this year, with employers instead turning to benefi...