303
EXTENDING FIREWORKS
Auto Shapes
Las
t
up
d
a
ted
12/8/2009
switch(smartShape.operation) {
case "BeginDragInsert":
case "InsertSmartShapeAt":
InsertSmartShapeAt(true);
break;
case "BeginDragControlPoint":
BeginDragControlPoint();
break;
case "DragControlPoint":
DragControlPoint();
break;
case "EndDragControlPoint":
EndDragControlPoint();
break;
case "SmartShapeEdited":
PlaceControlPoints();
break;
}
You don’t need a response for every message Fireworks sends; but you do need to make sure the
switch
statement
handles the responses required by your shape.
You can also invoke a single function for several messages:
case "BeginDragInsert":
case "InsertSmartShapeAt":
InsertSmartShapeAt(true);
break;
Supporting functions and methods
Because the Auto Shape file is written in JavaScript, your functions can use global variables, common functions, and
the Fireworks JavaScript API. The Auto Shape JavaScript file contains the definition of the shape’s points, and a series
of functions to handle the Fireworks messages as the user interacts with the shape. The file also includes a series of
commands and functions defining the shape’s properties and other functionality. These functions are often separate
from the message handling functions so they can be used by multiple message handling functions. For example, the
Cog Auto Shape JavaScript file (Configuration/Auto Shapes/Cog.jsf) contains user-defined functions near the bottom
of the file. These functions perform calculations and create shapes that are useful for the message handling functions.
The top of the file contains a series of variable statements that define useful values for tool tips, global variables, and
constants used throughout the Auto Shape JavaScript file.
You can use the Fireworks JavaScript API and the Fireworks Object Model, along with efficient JavaScript coding
practices, to create effective Auto Shapes (and continue to reuse the most useful functions from each Auto Shape
JavaScript file). For more information, see “
Additional Fireworks Functions
” on page 315 and the “
The Fireworks
Object Model
” on page 6.