[AS3]as3压缩位图BitmapData.encode用法源代码示例(3)
Button.as packagecom.vini123.tool { importflash.display.Sprite; importflash.events.MouseEvent; importflash.text.TextField; importflash.text.TextFieldAutoSize; importflash.text.TextFormat; publicclass
Button.as
- package com.vini123.tool
- {
- import flash.display.Sprite;
- import flash.events.MouseEvent;
- import flash.text.TextField;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFormat;
- public class Button extends Sprite
- {
- private var _txtFormat:TextFormat;
- private var _txt:TextField
- private var _bottom:Sprite;
- private var _gap:int =7;
- public function Button(label:String):void
- {
- _txtFormat = new TextFormat();
- _txtFormat.size = 13;
- _txtFormat.color = 0xADD0FC;
- _txt = new TextField();
- _txt.text = label;
- _txt.autoSize = TextFieldAutoSize.LEFT;
- _txt.setTextFormat(_txtFormat);
- _txt.mouseEnabled = false;
- addChild(_txt);
- _bottom = new Sprite();
- _bottom.graphics.lineStyle(1.0,0x2D72B5);
- _bottom.graphics.beginFill(0x0099ff,1);
- _bottom.graphics.drawRoundRect(0,0,_txt.textWidth + _gap *2,_txt.textHeight + _gap,5,5);
- _bottom.graphics.endFill();
- addChildAt(_bottom,0);
- _txt.x = _gap;
- _txt.y = _gap * 0.5 -1;
- this.addEventListener(MouseEvent.ROLL_OVER,overHandler);
- this.addEventListener(MouseEvent.ROLL_OUT,outHandler);
- }
- private function overHandler(e:MouseEvent):void
- {
- _txt.alpha = 0.65;
- }
- private function outHandler(e:MouseEvent):void
- {
- _txt.alpha = 1;
- }
- public function dispose():void
- {
- _bottom.graphics.clear();
- this.removeEventListener(MouseEvent.ROLL_OVER,overHandler);
- this.removeEventListener(MouseEvent.ROLL_OUT,outHandler);
- if(this.parent)
- {
- this.parent.removeChild(this);
- }
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...