Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Fireworks Developer Center /

Handling Fireworks events with ActionScript 3.0

by Mayur Mundada

Mayur Mundada
  • Adobe

Created

12 November 2007

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
ActionScript events extensibility Fireworks CS3 Flash Professional CS3 workflow

Requirements

Prerequisite knowledge

It's best to have a basic understanding of ActionScript 3.0, the Fireworks DOM, and working with JavaScript in Fireworks. Refer to the following articles by Trevor McCauley for more details on how to create custom panels (using ActionScript 2.0):

  • Creating Fireworks panels – Part 1: Introduction to custom panels
  • Creating Fireworks panels – Part 2: Advanced custom panel development

User Level

Advanced

Required products

  • Fireworks (Download trial)
  • Flash Professional (Download trial)

Sample files

  • fw_events_as3.zip (692 KB)

Custom panels are one of the features by which you can extend Fireworks to introduce new functionality into the tool or workflows into your team's procedures. You create or modify custom panels in Flash CS3 Professional and then export them as SWF files for use in Fireworks CS3. You can use ActionScript 2.0 or ActionScript 3.0 to extend these panels and handle Fireworks events.

This article focuses on handling Fireworks events in custom panels using ActionScript 3.0.

Receiving an event

When an event is generated in Fireworks, it calls the IsFwCallbackInstalled function in an ActionScript 3.0 SWF file to find out if the event handling code is written in the custom panel. If the function returns true, Fireworks first executes the event code written in the custom panel and then executes its own event handling code. Figure 1 depicts the control flow for a Fireworks event.

Control flow of a Fireworks event
Figure 1. Control flow of a Fireworks event

Part 2 of Trevor's "Creating Fireworks panels" series shows a table containing all the events generated by Fireworks. To take advantage of these events in ActionScript 3.0 with Fireworks CS3, you need to write two functions for your custom panel:

  • IsFwCallbackInstalled: This function is called by Fireworks to check if the event handler is written for the generated event.

    The following example returns true when Fireworks checks for the events related to a Fireworks document being opened or closed. This tells Fireworks that it should call handlers for those events for the custom panel when the actions occur:

function IsFwCallbackInstalled( funcName:String ):Boolean { switch( funcName ) { case "onFwDocumentOpen": return true; case "onFwDocumentClose": return true; case "setfwActiveToolForSWFs": return true; } return false; }
  • Event function: Your code for handling the event. This is the function you define to run commands that relate to the event as it happens in Fireworks. The following example shows event handlers for the onFwDocumentOpen and OnFwDocumentClose events. An alert message should pop up whenever a document is open (see Figure 2) or closed (see Figure 3):
function OpenDoc() { MMExecute('alert("Opening Document");'); }
Alert message when document is opened
Figure 2. Alert message when document is opened
function CloseDoc () { MMExecute('alert("Closing Document");'); }
Alert message when document is closed
Figure 3. Alert message when document is closed

Registering functions

You must register all functions written in ActionScript 3.0 that Fireworks calls. Fireworks cannot call any function in a custom panel that is not registered. In order to register a function, add the following line of code to it:

ExternalInterface.addCallback("<alias name>",<function name>);

where:

  • <alias name> is event function name that Fireworks calls
  • <function name> is the name of the function written in ActionScript 3.0

For example, to register IsFwCallbackInstalled, you would need to add the following line of code:

ExternalInterface.addCallback("IsFwCallbackInstalled",IsFwCallbackInstalled);

Similarly, for OpenDoc and CloseDoc, you would need to add the following lines of code, respectively:

ExternalInterface.addCallback("onFwDocumentOpen",OpenDoc); ExternalInterface.addCallback("onFwDocumentClose",CloseDoc);

ActionScript 3.0 functions that handle events are executed in Fireworks only if they and IsFwCallbackInstalled are registered, and if IsFwCallbackInstalled returns true when that event is generated.

Using the sample file

The sample file accompanying this article, fw_events_as3.zip, contains two files:

  • ActionScript.swf: Copy this file into the Fireworks installation folder:
    • Windows: C:\Program Files\Adobe\Adobe Fireworks CS3\Configuration\Command Panels
    • Mac OS: Hard Drive:Applications:Adobe Fireworks CS3:Configuration:Command Panels

    Now when you restart Fireworks, the new panel will be added. Select Windows > ActionScript to open this new panel (see Figure 4). This panel lists the current tool in use and shows the alert message whenever a document is opened or closed.

ActionScript panel showing current tool in use
Figure 4. ActionScript panel showing current tool in use
  • ActionScript.fla: This Flash CS3 Professional file contains the source code for the Fireworks panel. It explains how to capture the Fireworks event and handle it.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

More Like This

  • Foundation Fireworks excerpts: Visual effects and extending Fireworks
  • Developing an effective Fireworks workflow
  • Using the Color Palette panel in Fireworks CS3
  • Designing and prototyping Flex applications using Fireworks
  • Using the 3D Rotate command in Fireworks CS3
  • Using the Fireworks to XAML panel in Fireworks CS3
  • Using the Gradient panel in Fireworks CS3
  • Mobile workflows using Fireworks CS5 and Device Central CS5
  • Creating and exporting Fireworks graphics as FXG files for Flash Catalyst
  • Using the Guides panel in Fireworks CS3

Tutorials & Samples

Tutorials

  • Creating jQuery Mobile website themes in Fireworks
  • Extracting CSS properties from Fireworks design objects
  • Working with CSS sprites in Fireworks CS6

Samples

  • Twitter Trends
  • Flex 4.5 reference applications
  • Mobile Trader Flex app on Android Market

Fireworks Forum

More
04/19/2012 How to center multiple text in a button
04/22/2012 What exactly needs to be done to have my browser output text into a path that the user cannot type..
04/21/2012 Website Ranking
04/20/2012 Link problem with Fireworks CS5 - net::ERR_FILE_NOT_FOUND

Fireworks Cookbooks

More
09/07/2011 How do I use FXG XML markup in Shape subclasses?
10/15/2010 Flex4 Dotted Line
06/25/2010 ComboBox that uses a NativeMenu (Air API)
05/21/2010 Localizing a Creative Suite 5 extension

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement