flash位图技术研究篇(4): flash舞台屏幕录制
2010-03-02 00:00:00 来源:WEB开发网代码测试:
1. package
2. {
3.
4. import flash.display.Sprite;
5. import flash.events.*;
6. import flash.display.Bitmap;
7. import flash.display.BitmapData;
8. import flash.system.System;
9. import flash.utils.Timer;
10. public class Main extends Sprite
11. {
12. private var mypen:Pen=new Pen();
13. private var myscreen:FScreen=new FScreen();//创建录制
14. private var imagrList:Vector.<BitmapData>;
15. private var count:int=0;
16. private var time:Timer;
17. public function Main()
18. {
19.
20. addChild(mypen);
21. mypen.mouseListener();
22. mypen.addEventListener("StartDraw",StartDrawHandler);
23. mypen.addEventListener("Drawing",DrawingHandler);
24. mypen.addEventListener("EndDraw",EndDrawHandler);
25.
26. time=new Timer(200);//每200毫秒绘制一张图片
27. time.addEventListener(TimerEvent.TIMER,onTimer);
28.
29. stage.addEventListener(Event.ENTER_FRAME,Run);
30. Btn_end.addEventListener(MouseEvent.MOUSE_DOWN,keyEndHandler);
31. Btn_start.addEventListener(MouseEvent.MOUSE_DOWN,keyStartHandler);
32.
33. }
34.
35. private function StartDrawHandler(event:Event):void
36. {
37. mypen.startDraw();
38. }
39.
40. private function DrawingHandler(event:Event):void
41. {
42. mypen.drawing();
43. }
44.
45. private function EndDrawHandler(event:Event):void
46. {
47. mypen.stopDraw();
48. }
49.
50. //每一帧运行
51. private function Run(event:Event):void
52. {
53. //内存监控
54. Memory.text=System.totalMemory/1024+"/kb";
55. }
56.
57. private function keyEndHandler(event:MouseEvent):void
58. {
59. time.stop();//时间停止
60. addChild(myscreen.contain);
61. myscreen.play();
62. }
63.
64. private function keyStartHandler(event:MouseEvent):void
65. {
66. myscreen.removeScreen();//清楚画面
67. mypen.clearAll();
68. time.start();
69. }
70.
71. private function onTimer(event:TimerEvent):void
72. {
73. myscreen.copyScreen(this,stage.stageWidth,stage.stageHeight-20);//录制画面
74. trace("ww");
75. }
76.
77.
78. }
79.
80.
81. }
- ››FLASH不等于运算符!=的使用实例
- ››FLASH不全等运算符!==
- ››FLASH字符串分隔符运算符
- ››FLASH% 模运算符
- ››Flash+、++、+= 加法运算符
- ››Flash, 逗号运算符
- ››flash中的-、--、-=减法运算符
- ››Flash的-Infinity 常数、.点运算符、/ 除法运算符...
- ››Flash两种注释方法/*..*/ 和// 注释行分隔符运算符...
- ››Flash的/=除法赋值运算符、=赋值运算符、== 等于运...
- ››Flash之?: 条件运算符、^ 按位 XOR 运算符、^= 按...
- ››Flash的_framesloaded代码示例
更多精彩
赞助商链接