·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

[AS3]as3压缩位图BitmapData.encode用法源代码示例(3)

时间:2013-11-04 09:02cnblogs.com
Button.as packagecom.vini123.tool { importflash.display.Sprite; importflash.events.MouseEvent; importflash.text.TextField; importflash.text.TextFieldAutoSize; importflash.text.TextFormat; publicclass

Button.as

  1. package com.vini123.tool 
  2. { 
  3.     import flash.display.Sprite; 
  4.     import flash.events.MouseEvent; 
  5.     import flash.text.TextField; 
  6.     import flash.text.TextFieldAutoSize; 
  7.     import flash.text.TextFormat; 
  8.      
  9.     public class Button extends Sprite 
  10.     { 
  11.         private var _txtFormat:TextFormat; 
  12.         private var _txt:TextField 
  13.         private var _bottom:Sprite; 
  14.         private var _gap:int =7; 
  15.          
  16.         public function Button(label:String):void 
  17.         { 
  18.             _txtFormat = new TextFormat(); 
  19.             _txtFormat.size = 13; 
  20.             _txtFormat.color = 0xADD0FC; 
  21.              
  22.             _txt = new TextField(); 
  23.             _txt.text = label; 
  24.             _txt.autoSize = TextFieldAutoSize.LEFT; 
  25.             _txt.setTextFormat(_txtFormat); 
  26.             _txt.mouseEnabled = false; 
  27.             addChild(_txt); 
  28.              
  29.             _bottom = new Sprite(); 
  30.             _bottom.graphics.lineStyle(1.0,0x2D72B5); 
  31.             _bottom.graphics.beginFill(0x0099ff,1); 
  32.             _bottom.graphics.drawRoundRect(0,0,_txt.textWidth + _gap *2,_txt.textHeight + _gap,5,5); 
  33.             _bottom.graphics.endFill(); 
  34.             addChildAt(_bottom,0); 
  35.              
  36.             _txt.x = _gap; 
  37.             _txt.y = _gap * 0.5 -1; 
  38.              
  39.             this.addEventListener(MouseEvent.ROLL_OVER,overHandler); 
  40.             this.addEventListener(MouseEvent.ROLL_OUT,outHandler); 
  41.         } 
  42.          
  43.         private function overHandler(e:MouseEvent):void 
  44.         { 
  45.             _txt.alpha = 0.65; 
  46.         } 
  47.          
  48.         private function outHandler(e:MouseEvent):void 
  49.         { 
  50.             _txt.alpha = 1; 
  51.         } 
  52.          
  53.         public function dispose():void 
  54.         { 
  55.             _bottom.graphics.clear(); 
  56.             this.removeEventListener(MouseEvent.ROLL_OVER,overHandler); 
  57.             this.removeEventListener(MouseEvent.ROLL_OUT,outHandler); 
  58.             if(this.parent) 
  59.             { 
  60.                 this.parent.removeChild(this); 
  61.             } 
  62.         } 
  63.     } 
  64. } 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器