package draw1
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
[color="#339966"]//按钮类[/color]
public class draw_button extends MovieClip {
[color="#339966"]
//hit:能接受鼠标输入的区域
//sel:本按钮是否已经被选中
//
[/color]
var hit:Sprite=new Sprite();
var sel:Boolean =new Boolean();
[color="#339966"]
//
//函数名:draw_button//[/color]
//说明: 用来构建按钮
public function draw_button(){
this.buttonMode = true;
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
update();
[color="#339966"] //添加事件
[/color]
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
}
private function mouseDownListener(evt:MouseEvent){
if (this.sel==false){
update(2);
}else{
update();
}
}
private function mouseUpListener(evt:MouseEvent){
for (i=1;i
[color="#339966"]//设置按钮是否被选中[/color]
public function setSel(select:Boolean ){
this.sel=select;
}
[color="#339966"]//获取当前按钮的焦点状态[/color]
public function getSel():Boolean {
return this.sel;
}
[color="#339966"]//更新显示按钮,粗边框/细边框[/color]
public function update(lStyle:Number=0){
if (lStyle==0){
this.sel=false;
}else{
this.sel=true;
}
hit.graphics.clear();
hit.graphics.beginFill(0x888888,0.08);
hit.graphics.lineStyle(lStyle);
hit.graphics.drawRect(0,0,23.5,23.5);
hit.graphics.endFill();
this.addChild(hit);
}
}
}
本文转自:http://www.5uflash.com/flashjiaocheng/Flash-as3-jiaocheng/1944.html
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
[color="#339966"]//按钮类[/color]
public class draw_button extends MovieClip {
[color="#339966"]
//hit:能接受鼠标输入的区域
//sel:本按钮是否已经被选中
//
[/color]
var hit:Sprite=new Sprite();
var sel:Boolean =new Boolean();
[color="#339966"]
//
//函数名:draw_button//[/color]
//说明: 用来构建按钮
public function draw_button(){
this.buttonMode = true;
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
update();
[color="#339966"] //添加事件
[/color]
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
}
private function mouseDownListener(evt:MouseEvent){
if (this.sel==false){
update(2);
}else{
update();
}
}
private function mouseUpListener(evt:MouseEvent){
for (i=1;i
[color="#339966"]//设置按钮是否被选中[/color]
public function setSel(select:Boolean ){
this.sel=select;
}
[color="#339966"]//获取当前按钮的焦点状态[/color]
public function getSel():Boolean {
return this.sel;
}
[color="#339966"]//更新显示按钮,粗边框/细边框[/color]
public function update(lStyle:Number=0){
if (lStyle==0){
this.sel=false;
}else{
this.sel=true;
}
hit.graphics.clear();
hit.graphics.beginFill(0x888888,0.08);
hit.graphics.lineStyle(lStyle);
hit.graphics.drawRect(0,0,23.5,23.5);
hit.graphics.endFill();
this.addChild(hit);
}
}
}
本文转自:http://www.5uflash.com/flashjiaocheng/Flash-as3-jiaocheng/1944.html