CLICK HERE FOR A LIVE DEMONSTRATION OF THE TUTORIAL
On this tutorial we show how to start the drag through an event listener. The event listener will fire a function that starts the drag, stops the listener for mouse down and starts waiting for release.
DOWNLOAD THE TUTORIAL TO YOUR HARD DRIVE
Here is the Code!!
// Circle Flash Drag and Drop
// by Avraham Saltoun solutions at say-web dot com
// FREE to use, copy and Distribute.
//It all starts with an Event Listener
Circle_mc.addEventListener(MouseEvent.MOUSE_DOWN, Drag);
/*
The _mc enables CODE HINTING for Movie Clip
(The drop down with suggestions)
When the mouse button is clicked the compiler
will look and go for the Drag function */
function Drag (e:MouseEvent): void {
// The e represents the value beign recieved
// void is good practice to state no value
// will be return. Would work without it!
Circle_mc.startDrag();
Circle_mc.removeEventListener(MouseEvent.MOUSE_DOWN,Drag);
Circle_mc.addEventListener(MouseEvent.MOUSE_UP, Drop);
}
function Drop (e:MouseEvent):void
// Let’s copy and paste
// This will release the circle
// from the mouse!
{
Circle_mc.stopDrag();
Circle_mc.removeEventListener(MouseEvent.MOUSE_UP,Drop);
Circle_mc.addEventListener(MouseEvent.MOUSE_DOWN, Drag); }
// Thanks for Watching !!!!



































Wed, Aug 12, 2009
ActionScript