【实现效果】
点击画线按钮,拖动鼠标可以画任意线,点击清除按钮,则可以清除所有画线,也可以点击颜色按钮,选择另外的画线颜色,在画线的过程中,只再次点击画线按钮,则可以停止画线。
- 新建一影片剪辑,并在其中拖入三个按钮,即画线、清除、颜色按钮。
2.返回场景,拖入以上影片剪辑,在影片剪辑中输入代码:
onClipEvent(load){
candraw=-1;
this.lineStyle(2,0xff0000,100)
}
onClipEvent(mouseDown){
draw=true;
this.moveTo(_xmouse,_ymouse);
}
onClipEvent(mouseMove){
if(candraw==1 and draw==true){
this.lineTo(_xmouse,_ymouse)
}
updateAfterErent();
}
onClipEvent(mouseUp){
draw=-1;
}
3.双击进入影片编辑级别。
A.在画线按钮上写入代码:
On(release){
Candraw*=-1;
}
B.在清除按钮上写入代码:
On(release){
this.clear();
this.lineStyle(2,0xff0000,100)
}
C.在颜色按钮上写入代码:
On(release){
This.lineStyle(2,0x0000ff,100)
}