
MovieClip.clear() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
643
See Also
MovieClip.beginFill(), MovieClip.clear(), MovieClip.curveTo(), MovieClip.endFill(),
MovieClip.lineStyle(), MovieClip.lineTo(), MovieClip.moveTo(); Chapter 13
MovieClip.clear() Method
erases all Drawing API content from a movie clip
Flash 6
mc.clear()
Description
The clear() method erases all lines (strokes) and shapes (fills) created with the MovieClip
Drawing API methods in
mc, but it does not affect content created in the Flash authoring
tool. It also clears the current line style (as if lineStyle(undefined) were called) and returns
the drawing pen to position (0,0). To activate lines for subsequent drawings, call lineStyle()
before invoking any drawing methods.
You can’t erase author-time content using the Drawing API. Instead, use the
_visible
property to hide a movie clip.
Example
The following code draws a single line with a random line style on every frame. It uses
clear() to erase the line drawn in the previous frame:
// A custom function to return a random integer
Math.randomInt = function (minVal, maxVal) {
r = Math.random();
return minVal + Math.floor(r * (maxVal + 1 - minVal));
}
this.createEmptyMovieClip("drawing_mc", 1);
drawing_mc.onEnterFrame = function () {
this.clear();
this.lineStyle(Math.randomInt(1, 40), ...