MACROMEDIA FIREWORKS 8-EXTENDING FIREWORKS Spezifikationen Seite 17

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 35
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 16
205
EXTENDING FIREWORKS: DEVELOPING AN EFFECTIVE WORKFLOW USING JAVASCRIPT AND FLASH
complex projects that include large amounts of JSF. Instead of copying the JSF to a TextBlock, you
can export the JSF as a single ActionScript variable defined in an AS file, and then use ActionScript’s
#include to import the variable into your project. You then use MMExecute() just as you did with
the TextBlock, only this time passing it the variable name defined in the external AS file. This actu-
ally requires that you escape the entire JSF file again, something that we were trying to get you away
from earlier. Fortunately, this is not something you have to do manually. While creating the
FW to
XAML Exporter
panel, I created the Fireworks Developer Toolbox (FDT), a utility that does the escap-
ing and conversion to ActionScript for you automatically, which you’ll see how to use momentarily.
First, let’s review where we’ve come from and see how this latest solution is really just another evolu-
tion of the process. In the first MMExecute() examples, we defined the JSF string inline as the method
parameter:MMExecute("fw.popupColorPickerOverMouse();");.
We then moved the JSF directly to a TextBlock and accessed the TextBlock’s text property to exe-
cute JSF:MMExecute(jsfCode_txt.text);.
What we haven’t demonstrated is how to define a variable that houses the JSF code, and then pass that
variable to Fireworks via MMExecute(). In this approach, we have to escape the string values again:
var jsfCode:String = "fw.getDocumentDOM().setFillColor(\"”#FF0000\");";
MMExecute(jsfCode);
Taking this one step further, instead of defining the variable jsfCode inline in the Flash file, we can
create an external AS file that defines the variable:
// Contents of jsfCode.as
var jsfCode:String = "fw.popupColorPickerOverMouse();";
We can now use #include to include the contents of the external AS file. The variable jsfCode can be
accessed exactly as if it had been defined inline:
// ActionScript within Flash File
#include "jsfCode.as"
colorPicker_mc.onRelease = function()
{
// Execute JSF defined in jsfCode variable,
// housed in external jsfCode.as file
MMExecute(jsfCode);
}
This may seem like a step in the wrong direction, having to convert the JSF code to a string variable.
Fortunately, the FDT will do this automatically.
Converting JSF to AS using the FDT
Converting the JSF file to an ActionScript file is easy using the FDT. Launch the FDT (which is available
with the files for this chapter or at www.granthinkson.com/tools/fireworks), and then select the
ActionScript Conversion tab as shown in Figure 11-9. On this tab, you select your source JSF file and the
destination AS file, and define the ActionScript variable name that the JSF will be assigned to. Once
you’ve targeted your files and defined the variable name, just click the
convert button, and the AS file
will either be created or overwritten. You can also check the
Auto Convert when Source File Changed
Seitenansicht 16
1 2 ... 12 13 14 15 16 17 18 19 20 21 22 ... 34 35

Kommentare zu diesen Handbüchern

Keine Kommentare