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

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

To use an on handler and onPress event handler:
1.
Create a new Flash document and save it as handlers.fla.
2.
Select the Rectangle Tool and draw a large square on the Stage.
3.
Select the Selection Tool, double-click the square on the Stage, and press F8 to launch the
Convert to Symbol dialog box.
4.
Enter a symbol name for the box, set the type to Movie clip and click OK.
5.
Give the movie clip on the Stage an instance name of box_mc.
6.
Add the following ActionScript directly on the movie clip symbol on the Stage:
on (press) {
trace("on (press) {...}");
}
7.
Add the following ActionScript to Frame 1 of the main Timeline:
box_mc.onPress = function() {
trace("box_mc.onPress = function() {...};");
};
8.
Select Control > Test Movie to test the Flash document.
When you click the movie clip symbol on the Stage, the following output is sent to the
Output panel:
on (press) {...}
box_mc.onPress = function() {...};
Attaching
onClipEvent()
you should put your code in frame scripts or in a class file, as demonstrated
throughout this manual. For more information, see
on page 330
and
handlers is not a recommended practice. Instead,
on()
and
"Attaching code to objects" on page
"Using event handler methods"
746.
Using button and movie clip event handlers
339

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