About masking device fonts
You can use a movie clip to mask text that is set in a device font. In order for a movie clip mask on
a device font to work properly, the user must have Flash Player 6 (6.0.40.0) or later.
When you use a movie clip to mask text set in a device font, the rectangular bounding box of the
mask is used as the masking shape. That is, if you create a nonrectangular movie clip mask for
device font text in the Flash authoring environment, the mask that appears in the SWF file will be
the shape of the rectangular bounding box of the mask, not the shape of the mask itself.
You can mask device fonts only by using a movie clip as a mask. You cannot mask device fonts by
using a mask layer on the Stage.
Handling movie clip events
Movie clips can respond to user events, such as mouse clicks and keypresses, as well as system-level
events, such as the initial loading of a movie clip on the Stage. ActionScript provides two ways to
handle movie clip events: through event handler methods and through
event handlers. For more information, see
Assigning a class to a movie clip symbol
Using ActionScript 2.0, you can create a class that extends the behavior of the built-in MovieClip
class and then assign that class to a movie clip library symbol using the Linkage Properties dialog
box. Whenever you create an instance of the movie clip to which the class is assigned, it assumes
the properties and behaviors defined by the class assigned to it. (For more information about
ActionScript 2.0, see
page
247.)
In a subclass of the MovieClip class, you can provide method definitions for the built-in
MovieClip methods and event handlers, such as
procedure, you'll create a class called MoveRight that extends the MovieClip class; MoveRight
defines an
onPress
movie clip. In the second procedure, you'll create a movie clip symbol in a new Flash (FLA)
document and assign the MoveRight class to that symbol.
To create a movie clip subclass:
Create a new directory called BallTest.
1.
Create a new ActionScript file by doing one of the following:
2.
(Flash MX Professional 2004) Select File > New, and select ActionScript file from the list of
document types.
(Flash MX 2004) Create a text file in your preferred text editor.
Enter the following code in your script:
3.
// MoveRight class -- moves clip to the right 20 pixels when clicked
class MoveRight extends MovieClip {
function onPress() {
this._x += 20;
218
Chapter 8: Working with Movie Clips
Chapter 10, "Creating Custom Classes with ActionScript 2.0," on
handler that moves the clip 20 pixels to the right whenever the user clicks the
Chapter 5, "Handling Events," on page
and
onEnterFrame
and
onClipEvent()
167.
. In the following
onRelease
on()
Need help?
Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?