MACROMEDIA FIREWORKS 8-EXTENDING FIREWORKS Spezifikationen Seite 16

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 35
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 15
204
CHAPTER 11
In this method, the Flash Drawing API is used to draw a rectangle directly into an empty MovieClip
named rectTarget_mc. rectTarget_mc is prepositioned on the stage and serves as the selected color
swatch. The third line of ActionScript
(rectTarget_mc.beginFill(parseInt("0x" + color.substr(1, 6)), 100);)
demonstrates how to convert the color string returned from Fireworks into a hexadecimal value
that Flash can use in its beginFill method. This solid color conversion example is an easy one. The
Gradient panel that I wrote has to convert back and forth between the Fireworks gradient format and
the Flash gradient format constantly throughout its life cycle. After publishing the SWF (press Alt+F+B
or Shift/Cmd+F12) and testing Draw Rect.swf, the ColorPicker now works as expected, launching the
native Fireworks color picker and drawing the selected color in the Flash panel. However, there’s still
one piece missing: the
Add Rect button’s event handler needs to be updated to take advantage of the
selected color. Back to the code:
executeJSF_btn.onRelease = function() {
// Execute the JSF, creating the CreateRectangle function
MMExecute(jsfCode_txt.text);
// Calculate the CornerRadius value
var cornerRadius:Number = nsCornerRadius.value / 100;
// Call CreateRectangle
MMExecute("CreateRectangle(" + nsX.value + "," + nsY.value
+ "," + nsWidth.value + "," + nsHeight.value + ","
+ cornerRadius.toString() + ", '" + currentColor + "');");
}
Notice that the hard- coded #FF0000 color string has been replaced with the currentColor variable
in the second MMExecute() call. After publishing again, you can select a color, click
Add Rect, and the
selected color is applied as expected!
This is just one example of many cases where Fireworks and Flash values vary to a certain extent. You
have to know the differences between ActionScript requirements and the Fireworks object model and
convert these values into something that can be used.
Streamlining your workflow with the Fireworks
developer toolbox
So far we’ve shown you how to execute JSF inline via MMExecute() and by including the JSF in a
TextBlock on the design surface. You’ll never get away from the first method completely, but you
should not have to rely on it exclusively. The TextBlock method gives you a way to import your JSF
without having to escape all of your JSF. This is great for small chunks of JSF but introduces another
manual step that can result in errors. Having to copy and paste all of your JSF code from a text editor
to the design surface in Flash becomes laborious, and it’s one of those steps that can drive you crazy.
Fortunately, there’s another approach that can streamline your workflow even further, and it doesn’t
change the workflow proposed at the beginning of this chapter. It actually continues to enable it for
Seitenansicht 15
1 2 ... 11 12 13 14 15 16 17 18 19 20 21 ... 34 35

Kommentare zu diesen Handbüchern

Keine Kommentare