On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Galleries.
Dragging movie clips
You can use the global
make a movie clip draggable. For example, you can make a draggable movie clip for games,
drag-and-drop functions, customizable interfaces, scroll bars, and sliders.
A movie clip remains draggable until explicitly stopped by
movie clip is targeted with
SWF file.
To create more complicated drag-and-drop behavior, you can evaluate the
property of the movie clip being dragged. For example, you might examine the
property to see if the movie clip was dragged onto a specific movie clip (such as a "trash can"
movie clip) and then trigger another action, as shown in the following example:
// Drag a piece of garbage.
garbage_mc.onPress = function() {
this.startDrag(false);
};
// When the garbage is dragged over the trashcan, make it invisible.
garbage_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == trashcan_mc) {
garbage_mc._visible = false;
}
};
For more information, see
(
MovieClip.startDrag method)
You can a sample photo gallery application on your hard disk.This file provides an example of
how to use ActionScript to control movie clips dynamically while loading image files into a
SWF file, which includes making each movie clip draggable. You can find the sample source
file, gallery_tween.fla, in the Samples folder on your hard disk.
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\Galleries.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Galleries.
function or the
startDrag()
. Only one movie clip at a time can be dragged in a
startDrag()
startDrag function
in the ActionScript 2.0 Language Reference.
MovieClip.startDrag()
stopDrag()
or startDrag
Dragging movie clips
method to
or until another
_droptarget
_droptarget
359
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?