Comments
Patrick Collands wrote: collands (AT) gmail com I'd be very grateful for an invitation. Thank you.
Cloud Expo on Google News

SYS-CON.TV

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:
Click For 2008 West
Event Webcasts
Creating Panels in Macromedia Fireworks
When it comes to designing and optimizing web graphics, it doesn't get much better than Macromedia Fireworks

This new script combines each set of MMExecute commands into one. Replace it in Flash, republish, and retest:

right_btn.onRelease = function(){
    var command =
'fw.getDocumentDOM().moveSelectionBy(
{x:fw.selection[0].width, y:0}, true, false);'
    + 'fw.getDocumentDOM().reflectSelection
    (true, false, "autoTrimImages transformAttributes");';
    MMExecute(command);
}
left_btn.onRelease = function(){
    var command =
'fw.getDocumentDOM().moveSelectionBy(
{x:-fw.selection[0].width, y:0}, true, false);'
    + 'fw.getDocumentDOM().reflectSelection
    (true, false, "autoTrimImages transformAttributes");';
    MMExecute(command);
}
top_btn.onRelease = function(){
    var command = 'fw.getDocumentDOM().moveSelectionBy(
    {x:0, y:-fw.selection[0].height}, true, false);'
    + 'fw.getDocumentDOM().reflectSelection
    (false, true, "autoTrimImages transformAttributes");';
    MMExecute(command);
}
bottom_btn.onRelease = function(){
    var command = 'fw.getDocumentDOM().moveSelectionBy(
    {x:0, y:fw.selection[0].height}, true, false);'
    + 'fw.getDocumentDOM().reflectSelection
    (false, true, "autoTrimImages transformAttributes");';
    MMExecute(command);
}

Now using the Mirror panel should result in only one History step.

With everything complete and working properly, there is one more concern that you may want to address: code reuse. Mirroring an object in Fireworks is a potentially useful action. If you should ever want to perform this action again, it would be helpful to have an easily reusable snippet of code that would let you do so. At this point, the code is pretty divided, having different implementations between four different buttons. Using a single function to represent a mirror in any direction would be useful and reusable. Such a function may look like the following:

function mirror(horiz, vert){
    var dom = fw.getDocumentDOM();
    dom.moveSelectionBy({x:horiz*fw.selection[0].width,
    y:vert*fw.selection[0].height}, true, false);
    dom.reflectSelection(Boolean(horiz), Boolean(vert), "autoTrimImages
    transformAttributes"); }

Where horiz and vert represent directions of mirroring. Passing the value (­1, 0) to the mirror function mirrors to the left. Using (0, 1) mirrors to the bottom. Implemented in the Mirror panel, it looks like this:

var mirror = 'function mirror(horiz, vert){'
    + ' var dom = fw.getDocumentDOM();'
    + ' dom.moveSelectionBy({x:horiz*fw.selection[0].width,
    y:vert*fw.selection[0].height}, true, false);'
    + ' dom.reflectSelection(Boolean(horiz), Boolean(vert), "autoTrimImages
    transformAttributes");'
    + '}';
right_btn.onRelease = function(){
    MMExecute(mirror);
    MMExecute('mirror(1, 0);');
}
left_btn.onRelease = function(){
    MMExecute(mirror);
    MMExecute('mirror(-1, 0);');
}
top_btn.onRelease = function(){
    MMExecute(mirror);
    MMExecute('mirror(0, -1);');
}
bottom_btn.onRelease = function(){
    MMExecute(mirror);
    MMExecute('mirror(0, 1);');
}

You may notice that this script is back to using MMExecute twice again. It won't, however, create two steps in the History panel as the original version using two MMExecute commands for each mirror did. This is because Fireworks registers History steps from JavaScript commands only if there was some reaction made as a result of the executed command. Defining a function causes no such reaction so no History step is recorded. Actually, calling the function does cause the history to be recorded, so only the second call to MMExecute will result in a history step.

Where to Go from Here
The two panels I discussed in this tutorial provided very basic examples of custom panels in Fireworks. A lot of focus was directed towards workflow and debugging, helping you prepare for when you decide to develop more complicated panels.

In Creating Fireworks Panels ­ Part 2: Advanced Custom Panel Development, I cover a more complex example dealing with the advanced capabilities of custom panels in Fireworks. You will see how you can use the return result of MMExecute to dictate actions in Flash as well as learn how to create some more advanced interfaces for panels using some new features available in Studio 8.

Part 2 to this article can be found at www.macromedia.com/devnet.

About Trevor McCauley
Trevor McCauley first began working with Macromedia products while attending the University of Maryland, Baltimore County where he instructed classes and taught workshops covering Flash, Director, and Fireworks as an aside to earning a BA in Visual Arts. Currently Trevor works for a small production company developing content for websites and interactive CD/DVD ROMs. In his free time, he develops Flash and Fireworks content for his personal site, senocular.com, and moderates forums on popular Flash-related sites such as Kirupa.com, ActionScript.org, and UltraShock.com.

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

Register | Sign-in

Reader Feedback: Page 1 of 1

When it comes to designing and optimizing web graphics, it doesn't get much better than Macromedia Fireworks - given its available tools and workflow. However, Fireworks is not necessarily limited to the tools that come with it in the default installation. You can modify the interface to include new, custom panels that unlock hidden functionality, introduce new functionality, or simply improve your workflow.


Your Feedback
SYS-CON Australia News Desk wrote: When it comes to designing and optimizing web graphics, it doesn't get much better than Macromedia Fireworks - given its available tools and workflow. However, Fireworks is not necessarily limited to the tools that come with it in the default installation. You can modify the interface to include new, custom panels that unlock hidden functionality, introduce new functionality, or simply improve your workflow.
Latest Cloud Developer Stories
CloudBench Applications, Inc. announced its financial results for the three months and nine months ending September 30, 2009. All amounts are stated in Canadian dollars unless otherwise noted. Revenues from BasicGov, the Company's cloud computing solution for local government, gr...
The new contract is an industry first, with CSC being the first Microsoft partner to lead and win a cloud computing services agreement of this scale. Under terms of the contract, CSC will provide Royal Mail Group's 30,000 employees with access to new IT services using Microsoft's...
Operates in over 170 countries and is one of the world’s leading providers of communications solutions and services. Richard Tarboton talks for MeettheBoss.TV on his role as Head of Energy & Carbon for BT and what they are doing towards reducing carbon emissions.
CA is going to put its Agile Planner software on salesforce.com’s Force.com platform in the first half to accelerate development time and give users visibility over their development initiatives to reduce time-to-market. Customers are supposed to be able to accelerate the deploym...
Despite its uncertain fate Sun soldiers on. Monday it trotted out a cloud-based multiplatform desktop as a service for K-12 and community colleges that can run Windows, the Mac OS, Linux and Solaris applications to nearly any client device, including its own Sun Ray thin clients....
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
CloudBench Applications, Inc. announced its financial results for the three months and nine months e...