flash位图技术研究篇(4): flash舞台屏幕录制
2010-03-02 00:00:00 来源:WEB开发网 1. package
2. {
3. //画笔类
4. import flash.display.Sprite;
5. import flash.display.Shape;
6. import flash.events.*;
7. import flash.geom.Point;
8.
9. public class Pen extends Sprite
10. {
11. private var shape:Shape=new Shape();
12. private var begin:Boolean=false;
13. private var point:Point;
14. public function Pen()
15. {
16. addChild(shape);
17. }
18.
19. //监听
20. public function mouseListener():void
21. {
22.
23. stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
24. stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
25. stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
26. }
27. //开始绘制
28. public function startDraw():void
29. {
30. begin=true;
31. point=new Point(mouseX,mouseY);
32. shape.graphics.moveTo(point.x,point.y);
33. }
34.
35. public function drawing():void
36. {
37. if (begin)
38. {
39. drawLine(new Point(mouseX,mouseY));
40. }
41. }
42. //停止绘制
43. public function stopDraw():void
44. {
45. begin=false;
46. }
47.
48. private function mouseDownHandler(event:MouseEvent):void
49. {
50. this.dispatchEvent(new Event("StartDraw"));
51. }
52.
53. private function mouseUpHandler(event:MouseEvent):void
54. {
55. this.dispatchEvent(new Event("EndDraw"));
56.
57. }
58.
59. private function mouseMoveHandler(event:MouseEvent):void
60. {
61. this.dispatchEvent(new Event("Drawing"));
62. }
63.
64. //绘制线条
65. private function drawLine(point:Point):void
66. {
67. shape.graphics.lineStyle(2,0x000000);
68. shape.graphics.lineTo(point.x,point.y);
69. }
70.
71. //清楚所有
72. public function clearAll():void
73. {
74. shape.graphics.clear();
75. }
76.
77.
78. }
79.
80. }
- ››FLASH不等于运算符!=的使用实例
- ››FLASH不全等运算符!==
- ››FLASH字符串分隔符运算符
- ››FLASH% 模运算符
- ››Flash+、++、+= 加法运算符
- ››Flash, 逗号运算符
- ››flash中的-、--、-=减法运算符
- ››Flash的-Infinity 常数、.点运算符、/ 除法运算符...
- ››Flash两种注释方法/*..*/ 和// 注释行分隔符运算符...
- ››Flash的/=除法赋值运算符、=赋值运算符、== 等于运...
- ››Flash之?: 条件运算符、^ 按位 XOR 运算符、^= 按...
- ››Flash的_framesloaded代码示例
更多精彩
赞助商链接