WEB开发网
开发学院图形图像Flash flash位图技术研究篇(4): flash舞台屏幕录制 阅读

flash位图技术研究篇(4): flash舞台屏幕录制

 2010-03-02 00:00:00 来源:WEB开发网   
核心提示: 代码测试:1.package2.{3.4.importflash.display.Sprite;5.importflash.events.*;6.importflash.display.Bitmap;7.importflash.display.BitmapData;8.importflash.s

代码测试:

   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. }  

上一页  1 2 3 4 5  下一页

Tags:flash 位图 技术

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接