Adobe 65011817 Extended User Guide - Page 306
Switch statements
UPC - 883919157368
View all Adobe 65011817 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 306 highlights
Last updated 12/8/2009 EXTENDING FIREWORKS 302 Auto Shapes Function BeginDragControlPoint() Description Tells Fireworks what to do when the user clicks and holds the mouse button on a control point. Fireworks can change the object as the user moves the mouse (for example, using the RegisterMove method of the SmartShape object; for more information about how to get the properties of a smartShape object, see "ContourNode object" on page 239), or wait until after a mouse event to change the object. The following example uses the RegisterMove method to set the properties for the object on the mouse-down event so that the user can preview changes during the drag operation: DragControlPoint() EndDragControlPoint() SmartShapeEdited() function BeginDragControlPoint() { switch (smartShape.currentControlPointIndex) { case 0: var parms = smartShape.GetDefaultMoveParms(); smartShape.elem.controlPoints[0].RegisterMove(parms); smartShape.elem.elements[0].contours[0].nodes[0].RegisterMove(parms); break; } } This function is called every time the mouse moves during a drag operation. Fireworks can change the object as the user moves the mouse or wait until the mouse event ends to change the object. If the BeginDragControlPoint() function specifies control points or other points, Fireworks will not call the DragControlPoint() function. Tells Fireworks how to draw the final Auto Shape, after a drag operation is complete. If Fireworks handled shape changes through the BeginDragControlPoint() function, then you can use the end result of that function as a starting point. In that case, the code need not reflect every change in shape, but just the changes that aren't handled by BeginDragControlPoint(). This function is called when any changes have been made to the Auto Shape that might change the shape's behavior (such as removing a node inside an Auto Shape object). These functions correspond directly with the messages listed in "Fireworks messages" on page 300. 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: