MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 797

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

To define an event handler method in an object's prototype object:
1.
Create a movie clip symbol and set the linkage identifier to
in the Library panel and selecting Linkage from the Library pop-up menu.
2.
In the Actions panel (Window > Actions), use the
class, as shown in the following example:
// define a class
function myClipClass() {}
This new class is assigned to all instances of the movie clip that are added to the
application by the timeline or that are added to the application with the
or
duplicateMovieClip()
methods and properties of the built-in MovieClip object, you need to make the new class
inherit from the MovieClip class.
3.
Enter code, such as the following example:
// inherit from MovieClip class
myClipClass.prototype = new MovieClip();
Now, the class
myClipClass
MovieClip class.
4.
Enter code, such as the following example, to define the event handler methods for the
new class:
// define event handler methods for myClipClass class
myClipClass.prototype.onLoad = function() {trace("movie clip loaded");}
myClipClass.prototype.onEnterFrame = function() {trace("movie clip
entered frame");}
5.
Select Window > Library to open the Library panel if it isn't already open.
6.
Select the symbols that you want to associate with your new class, and select Linkage from
the Library panel pop-up menu.
7.
In the Linkage Properties dialog box, select Export for ActionScript.
8.
Enter a linkage identifier in the Identifier text box.
The linkage identifier must be the same for all symbols that you want to associate with the
new class. In the
9.
Enter code, such as the following example, in the Actions panel:
// register class
Object.registerClass("theID", myClipClass);
this.attachMovie("theID","myName",1);
method. If you want these movie clips to have access to the
inherits all the properties and methods of the
example, the identifier is
myClipClass
theID
function
theID
Defining event handler methods in ActionScript 1.0
by selecting the symbol
statement to define a new
attachMovie()
.
797

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

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?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents