User Guide
Creating an Auto Shape 129
These functions correspond directly with the messages listed in “Fireworks messages”
on page 126. To invoke your own function names in response to Fireworks messages, you
need to write a
switch() statement.
Switch statements
If you take a look at some existing Auto Shapes (in the Configuration/Auto Shapes folder and
in the Configuration/Auto Shape Tools folders), you’ll notice a
switch() statement near the
beginning of the file. The Auto Shape JavaScript code in these files uses a
switch() statement
as the initial message handler in the file. The
switch() statement sorts the messages sent by
Fireworks so each message (that is useful to the particular Auto Shape) invokes a
corresponding function.
You can see this
switch statement in each of the Auto Shape JavaScript files. Again, a single
Auto Shape object may not need to process every message Fireworks sends, so only the useful
messages are written into the JavaScript file using the
case qualifier. Effectively, the JavaScript
file states in case of a certain message, or messages, perform the following function.
In the Frame Auto Shape, this code is used to call
PlaceControlPoints() when Fireworks
sends a
"SmartShapeEdited" message:
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.