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

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

 2010-03-02 00:00:00 来源:WEB开发网   
核心提示: 1.package2.{3.//画笔类4.importflash.display.Sprite;5.importflash.display.Shape;6.importflash.events.*;7.importflash.geom.Point;8.9.publicclassPenextend

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

上一页  1 2 3 4 5  下一页

Tags:flash 位图 技术

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