MACROMEDIA FIREWORKS 8-EXTENDING FIREWORKS Spezifikationen Seite 14

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 35
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 13
202
CHAPTER 11
With all of the controls in place, with the exception of the ColorPicker, it’s now time to update
the ActionScript event handler for the
Add Rectangle button. The ColorPicker will be a little more
involved, so we’ll add it in a minute. Return to the executeJSF_btn.onRelease event handler on the
actions timeline and update the ActionScript with the following:
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() + ", '#FF0000');");
}
The first thing we do is execute the JSF contained in the TextBlock. Instead of the original JSF that
created a rectangle when executed, this just registers the function definition. Now the function
CreateRectangle will be available as long as Fireworks is running. After executing the JSF, the value
of the nsCornerRadius NumericStepper is divided by 100. This gives us a value in the 0–1 range—the
value expected by the Fireworks createRectanglePrimitive method. With those two housekeeping
steps out of the way, it’s now time to actually call the CreateRectangle function, passing it values
from Flash UI elements. Again, use MMExecute(), this time dynamically building the parameter string,
directly injecting the NumericStepper values. For now, we’ll use a hard- coded color value (#FF0000).
Later this value will be replaced with a value from the ColorPicker.
Working with returned values: Adding a ColorPicker
It’s great that we can now define the size and location of a rectangle from within our panel, but we’re
still missing the crucial color component. We could just add a TextBlock and accept a straight hexa-
decimal string, or we could take advantage of Fireworks’ built- in ColorPicker. Remember, just about
everything that the Fireworks core is capable of has been exposed via the API, and the ColorPicker
is no exception. We can launch the ColorPicker by calling the fw.popupColorPickerOverMouse()
method. Notice that this method is defined directly on the Fireworks (fw) object and not the DOM
object. This is because the ColorPicker itself isn’t performing an action on a specific document but is
instead providing general- purpose functionality. When called, the native Fireworks color picker will be
launched. Once a color is selected, the value will be returned in the #RRGGBBAA format. Figure 11-8
shows the command panel updated with a new MovieClip named ColorPicker_mc. This MovieClip
has a custom method named SetColor that, when called, paints the ColorPicker with the specified
color. (Open the sample files for this chapter to see how this is achieved.)
Seitenansicht 13
1 2 ... 9 10 11 12 13 14 15 16 17 18 19 ... 34 35

Kommentare zu diesen Handbüchern

Keine Kommentare