MACROMEDIA FIREWORKS 8-EXTENDING FIREWORKS Spezifikationen Seite 8

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 35
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 7
196
CHAPTER 11
Steps 3 and 4: Importing and executing the JSF
Flash panels pass JSF to Fireworks via the MMExecute() method in ActionScript. When an exported
SWF is run inside Fireworks as a Flash panel, MMExecute() passes the JavaScript directly to Fireworks.
Fireworks then executes the JavaScript and returns the resulting value to Flash (if any):
var result = MMExecute(jsfCode);
The JavaScript is passed to MMExecute() as a string, which means you must escape quotation marks
and potentially double- escape text that has already been escaped in JavaScript strings. That sounds
more confusing than it actually is. The following example executes the setFillColor() line of code
in Flash using MMExecute():
MMExecute("fw.getDocumentDOM().setFillColor(\"#99cc33\");");
Notice that the entire string is wrapped with quotation marks, and the inner quotes surrounding
#99cc33 have been escaped: \"#99cc33\". For single lines of JavaScript, this method of execution
works well. As your JavaScript grows in complexity, however, escaping large sequences of code
becomes laborious and introduces the potential for error.
One way around this for simple commands is to paste the JSF into a Flash TextField. Let’s use this
approach for our Draw Rect example:
1. Create a new TextField on the stage.
2. Change its text type to Dynamic Text and give it an instance name of jsfCode_txt (see
Figure 11-3).
3. Move this TextField off the stage so that it is not visible at runtime.
4. Paste the contents of the Draw Rect command directly into this TextField.
The Fireworks JavaScript is now available to you directly within the Flash document, accessible via
jsfCode_txt.text, and you didn’t have to make any modifications to the code at all.
Seitenansicht 7
1 2 3 4 5 6 7 8 9 10 11 12 13 ... 34 35

Kommentare zu diesen Handbüchern

Keine Kommentare