Adobe
Produits
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Autres produits
Solutions
Marketing numérique
Médias numériques
Éducation
Services financiers
Administration
Web Experience Management
Autres solutions
Formation Aide Téléchargements Société
Acheter
Utilisation privée pour les particuliers et les travailleurs à domicile
Éducation pour les étudiants, les enseignants et le personnel administratif
Point de vente professionnel pour les petites et moyennes entreprises
Programmes de licences pour les entreprises, les établissements d'enseignement et l'administration
Autres options d'achat
Offres spéciales
Rechercher
 
Informations Se connecter
Bienvenue, Mon panier Mes commandes Mon Adobe
Mon Adobe
Mes commandes
Mes informations
Mes préférences
Déconnexion
Pourquoi dois-je me connecter ? Connectez-vous pour pouvoir gérer votre compte et accéder aux versions d'évaluation téléchargeables, aux extensions de produits, aux communautés, etc.
Adobe
Produits Rubriques Buy   Rechercher  
Solutions Société
Aide Formation
Se connecter Déconnexion Mes commandes Mon Adobe
Date de disponibilité estimée en précommandeDate. Votre carte bancaire sera débitée à l'expédition du produit. La date de disponibilité estimée est sujette à modification. Date de disponibilité estimée en précommandeDate. Votre carte bancaire sera débitée lorsque le produit sera disponible en téléchargement. La date de disponibilité estimée est sujette à modification.
Qté:
Votre achat est soumis à la vérification de votre éligibilité
Sous-total
Vérifier et régler
Adobe Developer Connection / Pôle de développement Fireworks /

Handling Fireworks events with ActionScript 3.0

par Mayur Mundada

Mayur Mundada
  • Adobe

Created

12 November 2007

Partage

Partager sur Facebook
Partager sur Twitter
Partager sur LinkedIn
Signet
Imprimer

Tags

ActionScript events extensibility Fireworks CS3 Flash Professional CS3 workflow

Configuration requise

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

Avancé

Produits requis

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

Fichiers exemples

  • 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

  • Designing and prototyping Flex applications using Fireworks
  • Creating Fireworks Panels – Part 1: Introduction to Custom Panels
  • Foundation Fireworks excerpts: Visual effects and extending Fireworks
  • Developing an effective Fireworks workflow
  • Fireworks in enterprise IT
  • Using the 3D Rotate command in Fireworks CS3
  • Using the Color Palette panel in Fireworks CS3
  • Using the Guides panel in Fireworks CS3
  • Enhancing rich symbols in Fireworks CS3
  • Designing interactive products with Fireworks

Produits

  • Acrobat
  • Applications mobiles
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Photoshop
  • Touch Apps

Solutions

  • Marketing numérique
  • Médias numériques
  • Web Experience Management

Secteurs d'activité

  • Éducation
  • Services financiers
  • Administration

Aide

  • Centres d'aide sur les produits
  • Commandes et retours
  • Téléchargement et installation
  • Mon Adobe

Formation

  • Adobe Developer Connection
  • Adobe TV
  • Formation et certification
  • Forums
  • Pôle de création

Options d'achat

  • Pour les particuliers et les travailleurs à domicile
  • Pour les étudiants, les enseignants et le personnel administratif
  • Pour les petites et moyennes entreprises
  • Pour les entreprises, les établissements d'enseignement et l'administration
  • Offres spéciales

Téléchargements

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

Société

  • Salle de presse
  • Programmes partenaires
  • Responsabilité sociale de l'entreprise
  • Offres d'emploi
  • Relations avec les investisseurs
  • Événements
  • Secteur juridique
  • Sécurité
  • Contacter Adobe
Sélectionnez votre pays France (modifier)
Sélectionnez votre région/pays Fermer

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.

Conditions d'utilisation | Politique de confidentialité et cookies (Mise à jour)

Choix de Pub