MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual page 107

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

Creating a simple line drawing tool
You can use methods of the MovieClip class to draw lines and fills on the Stage as the SWF file
plays. This allows you to create drawing tools for users and to draw shapes in the SWF file in
response to events. The drawing methods are
,
curveTo()
endFill()
to any movie clip instance (for instance,
The
and
lineTo()
line color, thickness, and alpha setting for a line or curve with the
drawing method sets the current drawing position to x and y Stage coordinates
moveTo()
you specify.
The
beginFill()
fill, respectively, and
beginGradientFill()
clip object.
For more information, see
MovieClip.beginGradientFill()
MovieClip.curveTo()
MovieClip.lineTo()
MovieClip.moveTo()
To create a simple line drawing tool:
In a new document, create a button on the Stage, and enter
1
the Property inspector.
Select Frame 1 in the Timeline; then select Window > Development Panels > Actions to open
2
the Actions panel if it's not already visible.
In the Actions panel, enter the following code:
3
_root.onMouseDown = function() {
_root.lineStyle(5, 0xFF0000, 100);
_root.moveTo(_root._xmouse, _root._ymouse);
isDrawing = true;
};
_root.onMouseMove = function() {
if (isDrawing == true) {
_root.lineTo(_root._xmouse, _root._ymouse);
updateAfterEvent();
}
};
_root.onMouseUp = function() {
isDrawing = false;
};
clear_btn.onRelease = function() {
_root.clear();
};
Select Control > Test Movie to test the movie. Click and drag your mouse to draw a line on the
4
Stage. Click the button to erase what you've drawn.
,
,
lineTo()
lineStyle()
myClip.lineTo()
methods let you draw lines and curves, respectively. You specify a
curveTo()
and
beginGradientFill()
applies the fill specified in the last call to
endFill()
. The
method erases what's been drawn in the specified movie
clear()
MovieClip.beginFill()
on page
on page
496,
MovieClip.endFill()
on page
511,
MovieClip.lineStyle()
on page
516.
,
beginFill()
beginGradientFill()
, and
. You can apply these methods
moveTo()
) or to a level (
lineStyle()
methods fill a closed path with a solid or gradient
on page
489,
490,
MovieClip.clear()
on page
on page
clear_btn
Creating interactivity and visual effects
,
clear()
).
_root.curveTo()
method. The
or
beginFill()
on page
493,
499,
510, and
as the instance name in
,
107

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents