![MACROMEDIA DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER Manual Download Page 100](http://html1.mh-extra.com/html/macromedia/dreamweaver-mx-2004-extending-dreamweaver/dreamweaver-mx-2004-extending-dreamweaver_manual_3335562100.webp)
100
Chapter 4: Auto Shapes
These functions correspond directly with the messages listed in
“Fireworks messages” on page 98
.
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.
You can also invoke a single function for several messages:
case "BeginDragInsert":
case "InsertSmartShapeAt":
InsertSmartShapeAt(true);
break;
Summary of Contents for DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER
Page 1: ...Extending Fireworks...
Page 4: ...4 Contents...
Page 8: ...8 Chapter 1 Extending Fireworks Overview...
Page 102: ...102 Chapter 4 Auto Shapes...