Example
The following example draws a box on the Stage. When the user clicks the box graphic, it
removes the graphic from the Stage.
this.createEmptyMovieClip("box_mc", this.getNextHighestDepth());
box_mc.onRelease = function() {
this.clear();
};
drawBox(box_mc, 10, 10, 320, 240);
function drawBox(mc:MovieClip, x:Number, y:Number, w:Number, h:Number):Void
{
mc.lineStyle(0);
mc.beginFill(0xEEEEEE);
mc.moveTo(x, y);
mc.lineTo(x+w, y);
mc.lineTo(x+w, y+h);
mc.lineTo(x, y+h);
mc.lineTo(x, y);
mc.endFill();
}
The
MovieClip.getNextHighestDepth()
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
An example is also in the drawingapi.fla file in the Samples\ActionScript\DrawingAPI folder.
The following list gives typical paths to this folder:
Windows: \Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript
Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/
ActionScript
See also
lineStyle (MovieClip.lineStyle method)
createEmptyMovieClip
(MovieClip.createEmptyMovieClip method)
public createEmptyMovieClip(name:String, depth:Number) : MovieClip
Creates an empty movie clip as a child of an existing movie clip. This method behaves
similarly to the
attachMovie()
identifier for the new movie clip. The registration point for a newly created empty movie clip
is the upper-left corner. This method fails if any of the parameters are missing.
848
ActionScript classes
method used in this example requires Flash Player
MovieClip.getNextHighestDepth()
method, but you don't need to provide an external linkage
method.
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?