· 在线留言 · 关于我们
全国7X24小时服务热线:
029-8831-1253
 
当前位置:首页>信息化频道>信息技术

信息技术

实现选择按钮被点击的状态
西安软件公司, 西安软件开发 http://www.jzsoftit.com , 西安网站建设, 西安网站制作 http://www.jzsoftit.cn
按钮一般会有三种状态。。。
但选择按钮被点击后,如果想区别于没有被点击的按钮的时候。在FLASH中,是比较难实现的。
以下是效果跟代码:


//AS3培训官方网站 http://www.flashdown.net
var myarray:Array=new Array();
for (var i:uint=1; i<4; i++) {
  this["btn" + i].addEventListener(MouseEvent.CLICK,_CLICK);
  this["btn" + i].addEventListener(MouseEvent.MOUSE_OVER,_OVER);
  this["btn" + i].addEventListener(MouseEvent.MOUSE_OUT,_OUT);
  myarray.push(this["btn" + i]);
}
function _CLICK(e:MouseEvent):void {
  e.currentTarget.gotoAndStop(3);
  e.target.removeEventListener(MouseEvent.MOUSE_OVER,_OVER);
  e.target.removeEventListener(MouseEvent.MOUSE_OUT,_OUT);
  for (var i:uint=1; i<4; i++) {
    if (e.target!=myarray[i-1]) {
      myarray[i - 1].gotoAndStop(1);
      myarray[i - 1].addEventListener(MouseEvent.MOUSE_OVER,_OVER);
      myarray[i - 1].addEventListener(MouseEvent.MOUSE_OUT,_OUT);
    }
  }

}
function _OVER(e:MouseEvent):void {
  e.currentTarget.gotoAndStop(2);

}
function _OUT(e:MouseEvent):void {
  e.currentTarget.gotoAndStop(1);
}

或者这种方法也可以:
for (var i:uint=1; i<4; i++) {
  this["btn" + i].addEventListener(MouseEvent.CLICK,_CLICK);
  this["btn" + i].addEventListener(MouseEvent.MOUSE_OVER,_OVER);
  this["btn" + i].addEventListener(MouseEvent.MOUSE_OUT,_OUT);
  this["btn" + i].I=i;
}
function _CLICK(e:MouseEvent):void {
  for (var j:uint=1; j<4; j++) {
    this["btn" + j].gotoAndStop(1);
    this["btn" + j].addEventListener(MouseEvent.MOUSE_OVER,_OVER);
    this["btn" + j].addEventListener(MouseEvent.MOUSE_OUT,_OUT);
    if (e.currentTarget.I==j) {
      e.currentTarget.removeEventListener(MouseEvent.MOUSE_OVER,_OVER);
      e.currentTarget.removeEventListener(MouseEvent.MOUSE_OUT,_OUT);
      e.currentTarget.gotoAndStop(3);
    }
  }
}
function _OVER(e:MouseEvent):void {
  e.currentTarget.gotoAndStop(2);
}
function _OUT(e:MouseEvent):void {
  e.currentTarget.gotoAndStop(1);
}

 

关于我们  | 果蔬质量追溯系统  | 网站建设  | 网站推广  | 网站运营  | 软件开发  | 软硬件集成  | 软件选型  | 软件外包  | 系统托管  | 成功案例   | IT硬件  | 常见问题  | 在线留言  |  联系方式
  © 2005 www.jzsoftit.com  西安捷众软件科技有限公司 版权所有
地址:西安市高新区科技路东口中天国际B座19层 电话:029-88311253   QQ:1009213309  Email:jzsoftit@163.com