-
Flash - --- ->>
Summary 123
7 Create an ActionScript file by doing one of the following:
■If you ’re using Flash MX 2004 Professional,select File >New >ActionScript File (Not Flash
Document).Save the document with the name Drag,in the same location where you saved
Shape.fla.
■If you ’re using Flash MX 2004,open a text editor,such as Notepad.Save the file with the
name Drag.as,in the same location where you saved Shape.fla.
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 document.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 116..
Summary
Congratulations on learning how to work with objects and classes in ActionScript 2.0.In a few
minutes,you learned how to accomplish the following tasks:
•Create and use objects from existing classes
•Create a custom class
•Create a property within a custom class
•Create a method within a custom class
•Extend an existing class and take advantage of inheritance
-
what's the point of posting out these tutorials??? in separate posts....
you're just doing it to get your post numbers up... it's just as good as spamming
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks