Welcome!

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

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) View Comments

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.


Most Recent Comments
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

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

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.

@ThingsExpo Stories
Amazon started as an online bookseller 20 years ago. Since then, it has evolved into a technology juggernaut that has disrupted multiple markets and industries and touches many aspects of our lives. It is a relentless technology and business model innovator driving disruption throughout numerous ecosystems. Amazon’s AWS revenues alone are approaching $16B a year making it one of the largest IT companies in the world. With dominant offerings in Cloud, IoT, eCommerce, Big Data, AI, Digital Assista...
The Founder of NostaLab and a member of the Google Health Advisory Board, John is a unique combination of strategic thinker, marketer and entrepreneur. His career was built on the "science of advertising" combining strategy, creativity and marketing for industry-leading results. Combined with his ability to communicate complicated scientific concepts in a way that consumers and scientists alike can appreciate, John is a sought-after speaker for conferences on the forefront of healthcare science,...
In his session at Cloud Expo, Alan Winters, U.S. Head of Business Development at MobiDev, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to maximize project result...
In his keynote at 19th Cloud Expo, Sheng Liang, co-founder and CEO of Rancher Labs, discussed the technological advances and new business opportunities created by the rapid adoption of containers. With the success of Amazon Web Services (AWS) and various open source technologies used to build private clouds, cloud computing has become an essential component of IT strategy. However, users continue to face challenges in implementing clouds, as older technologies evolve and newer ones like Docker c...
Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at Cloud Expo, Ed Featherston, a director and senior enterprise architect at Collaborative Consulting, discussed the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
Personalization has long been the holy grail of marketing. Simply stated, communicate the most relevant offer to the right person and you will increase sales. To achieve this, you must understand the individual. Consequently, digital marketers developed many ways to gather and leverage customer information to deliver targeted experiences. In his session at @ThingsExpo, Lou Casal, Founder and Principal Consultant at Practicala, discussed how the Internet of Things (IoT) has accelerated our abilit...
When shopping for a new data processing platform for IoT solutions, many development teams want to be able to test-drive options before making a choice. Yet when evaluating an IoT solution, it’s simply not feasible to do so at scale with physical devices. Building a sensor simulator is the next best choice; however, generating a realistic simulation at very high TPS with ease of configurability is a formidable challenge. When dealing with multiple application or transport protocols, you would be...
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
Two weeks ago (November 3-5), I attended the Cloud Expo Silicon Valley as a speaker, where I presented on the security and privacy due diligence requirements for cloud solutions. Cloud security is a topical issue for every CIO, CISO, and technology buyer. Decision-makers are always looking for insights on how to mitigate the security risks of implementing and using cloud solutions. Based on the presentation topics covered at the conference, as well as the general discussions heard between sessio...
Detecting internal user threats in the Big Data eco-system is challenging and cumbersome. Many organizations monitor internal usage of the Big Data eco-system using a set of alerts. This is not a scalable process given the increase in the number of alerts with the accelerating growth in data volume and user base. Organizations are increasingly leveraging machine learning to monitor only those data elements that are sensitive and critical, autonomously establish monitoring policies, and to detect...
In his session at @ThingsExpo, Arvind Radhakrishnen discussed how IoT offers new business models in banking and financial services organizations with the capability to revolutionize products, payments, channels, business processes and asset management built on strong architectural foundation. The following topics were covered: How IoT stands to impact various business parameters including customer experience, cost and risk management within BFS organizations.
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. 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 settl...
IoT solutions exploit operational data generated by Internet-connected smart “things” for the purpose of gaining operational insight and producing “better outcomes” (for example, create new business models, eliminate unscheduled maintenance, etc.). The explosive proliferation of IoT solutions will result in an exponential growth in the volume of IoT data, precipitating significant Information Governance issues: who owns the IoT data, what are the rights/duties of IoT solutions adopters towards t...
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
Organizations planning enterprise data center consolidation and modernization projects are faced with a challenging, costly reality. Requirements to deploy modern, cloud-native applications simultaneously with traditional client/server applications are almost impossible to achieve with hardware-centric enterprise infrastructure. Compute and network infrastructure are fast moving down a software-defined path, but storage has been a laggard. Until now.
DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
The best way to leverage your CloudEXPO | DXWorldEXPO presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering CloudEXPO | DXWorldEXPO will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at CloudEXPO. Product announcements during our show provide your company with the most reach through our targeted audienc...
IoT is at the core or many Digital Transformation initiatives with the goal of re-inventing a company's business model. We all agree that collecting relevant IoT data will result in massive amounts of data needing to be stored. However, with the rapid development of IoT devices and ongoing business model transformation, we are not able to predict the volume and growth of IoT data. And with the lack of IoT history, traditional methods of IT and infrastructure planning based on the past do not app...