beautypg.com

Apply the control shockwave or swf behavior, Apply the drag ap element behavior – Adobe Dreamweaver CC 2015 User Manual

Page 424

background image

417

Javascript

Last updated 6/3/2015

Apply the Control Shockwave or SWF behavior

This behavior has been deprecated as of Dreamweaver CS5.

Apply the Drag AP Element behavior

The Drag AP Element behavior lets the visitor drag an absolutely positioned (AP) element. Use this behavior to create
puzzles, slider controls, and other movable interface elements.

You can specify in which direction the visitor can drag the AP element (horizontally, vertically, or in any direction), a
target to which the visitor should drag the AP element, whether to snap the AP element to the target if the AP element
is within a certain number of pixels of the target, what to do when the AP element hits the target, and more.

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 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.