The Drag Layer action lets the visitor drag a layer. Use this action to create puzzles, slider controls, and other movable interface elements.
You can specify in which direction the visitor can drag the layer (horizontally, vertically, or in any direction), a target to which the visitor should drag the layer, whether to snap the layer to the target if the layer is within a certain number of pixels of the target, what to do when the layer hits the target, and more.
Because the Drag Layer action must be called before the layer can be dragged by the visitor, make sure the event that triggers the action occurs before the visitor attempts to drag the layer. Its best to attach Drag Layer to the body
object (with the onLoad
event), though you can also attach it to a link that fills the entire layer (such as a link around an image) using the onMouseOver
event.
body
tag by clicking <body>
in the tag selector at the bottom of the Document window.
If Drag Layer is unavailable, you probably have a layer selected. Because layers do not accept events in both 4.0 browsers, you must select a different object--such as the body
tag or a link (a
tag)--or change the target browser to Internet Explorer 4.0 in the Show Events For 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.
Values are relative to the starting position of the layer. To constrain movement within a rectangular region, enter positive values in all four text 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.
The drop target is the spot to which you want the visitor to drag the layer. A layer is considered to have reached the drop target when its left and top coordinates match the values you enter in the Left and Top text 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 layer.
Larger values make it easier for the visitor to find the drop target.
This option is useful when the image inside the layer has 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 layer to drag it.
monitorLayer()
) in the Call JavaScript text box to repeatedly execute the code or function while the layer is being dragged. For example, you could write a function that monitors the coordinates of the layer and displays hints such as "youre getting warmer" or "youre nowhere near the drop target" in a text box. For more information, see Gathering information about the draggable layer.If it isnt, select another event from the pop-up menu. If the events you want are not listed, change the target browser in the Show Events For pop-up menu. Remember that layers are not supported by 3.0 browsers.
NOTE |
|
You cannot attach the Drag Layer action to an object with the |