User Guide
266 ActionScript: Work with Objects and Classes
8. In the ActionScript file that you just created, create a new class and
constructor called
Drag:
class Drag extends MovieClip
{
function Drag ()
{
onPress=doDrag;
onRelease=doDrop;
}
}
9.
Define private methods in the class that use the existing movie clip
methods,
startDrag() and stopDrag():
class Drag extends MovieClip
{
function Drag()
{
onPress=doDrag;
onRelease=doDrop;
}
private function doDrag():Void
{
this.startDrag();
}
private function doDrop():Void
{
this.stopDrag()
}
}
10.
Save the ActionScript file.
11. Test the Shape.fla file.
You should be able to drag the movie clip.
NOTE
An example of the ActionScript file you just created, named Drag.as, is
located in your finished files folder. For the path, see “Set up your
workspace” on page 256.