先看效果:
制作非常简单,新建立文档,然后按Ctrl+J修改属性。
按Ctrl+R导入一幅图片,或者自己绘制一幅铅笔图。
按F8转变为元件。
为该元件设置实例名。
选择第一帧,添加如下Action。
this.attachMovie("cursor_id", "cursor_mc", this.getNextHighestDepth(),
{_x:_xmouse, _y:_ymouse});
Mouse.hide();
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
pencil._x = _xmouse;
pencil._y = _ymouse;
updateAfterEvent();
};//建立一个铅笔图标
Mouse.addListener(mouseListener);//和铅笔图片联系在一起
this.createEmptyMovieClip("drawing_mc", this.getNextHighestDepth());
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
this.drawing = true;
drawing_mc.moveTo(_xmouse, _ymouse);
drawing_mc.lineStyle(3, 0x99CC00, 100);
};
mouseListener.onMouseUp = function() {
this.drawing = false;
};
mouseListener.onMouseMove = function() {
if (this.drawing) {
drawing_mc.lineTo(_xmouse, _ymouse);
}
updateAfterEvent();
};
Mouse.addListener(mouseListener);
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.DELETEKEY) || Key.isDown(Key.BACKSPACE)) {
drawing_mc.clear();
}
};
Key.addListener(keyListener);
按Ctrl+Enter测试吧!