Adobe Flex Authors: Matthew Lobas, PR.com Newswire, Shelly Palmer, Kevin Benedict

Related Topics: Adobe Flex

Adobe Flex: Article

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;
fw.selection = stored_selection;

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.

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.

Comments (2)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

IoT & Smart Cities Stories
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...