Operation Manual
333
USING DREAMWEAVER
Adding JavaScript behaviors
Last updated 3/28/2012
Because the Drag AP Element behavior must be called before the visitor can drag the AP element, you should attach
Drag AP Element to the
body object (with the onLoad event).
1 Select Insert > Layout Objects > AP Div or click the Draw AP Div button on the Insert panel and draw an AP Div
in the Document window’s Design view.
2 Click <body> in the tag selector at the lower-left corner of the Document window.
3 Select Drag AP Element from the Add Behavior menu of the Behaviors panel.
If Drag AP Element is unavailable, you probably have an AP element selected.
4 In the AP Element pop-up menu, select the AP element.
5 Select either Constrained or Unconstrained from the Movement pop-up menu.
Unconstrained movement is appropriate for puzzles and other drag-and-drop games. For slider controls and
moveable scenery such as file drawers, curtains, and mini-blinds, select constrained movement.
6 For constrained movement, enter values (in pixels) in the Up, Down, Left, and Right boxes.
Values are relative to the starting position of the AP element. To constrain movement within a rectangular region, enter
positive values in all four boxes. To allow only vertical movement, enter positive values for Up and Down and 0 for Left
and Right. To allow only horizontal movement, enter positive values for Left and Right and 0 for Up and Down.
7 Enter values (in pixels) for the drop target in the Left and Top boxes.
The drop target is the spot to which you want the visitor to drag the AP element. An AP element is considered to have
reached the drop target when its left and top coordinates match the values you enter in the Left and Top boxes. Values
are relative to the top left corner of the browser window. Click Get Current Position to automatically fill the text boxes
with the current position of the AP element.
8 Enter a value (in pixels) in the Snap If Within box to determine how close the visitor must get to the drop target
before the AP element snaps to the target.
Larger values make it easier for the visitor to find the drop target.
9 For simple puzzles and scenery manipulation, you can stop here. To define the drag handle for the AP element,
track the movement of the AP element while it is being dragged, and trigger an action when the AP element is
dropped, click the Advanced tab.
10 To specify that the visitor must click a particular area of the AP element to drag the AP element, select Area within
element from the Drag Handle menu; then enter the left and top coordinates and the width and height of the drag
handle.
This option is useful when the image inside the AP element contains an element that suggests dragging, such as a title
bar or drawer handle. Do not set this option if you want the visitor to be able to click anywhere in the AP element to
drag it.
11 Select any While Dragging options that you want to use:
• Select Bring Element To Front if the AP element should move to the front of the stacking order while it is being
dragged. If you select this option, use the pop-up menu to select whether to leave the AP element in front or restore
it to its original position in the stacking order.
• Enter JavaScript code or a function name (for example, monitorAPelement()) in the Call JavaScript box to
repeatedly execute the code or function while the AP element is being dragged. For example, you could write a
function that monitors the coordinates of the AP element and displays hints such as “you’re getting warmer” or
“you’re nowhere near the drop target” in a text box.