as实现css风格菜单

 

var navArray = ["个人简介","作品展示","学习中心","联系我吧","友情链接"]
// correct colors in menu
function setupMenu () {
 
 // colors
 BaseColor = 0x414042;
 RolloverColor = 0xCCC2C0;
 SelectedColor = 0xF15B40;
 
 // buttons
 for (var i=1; i<=5; ++i) {
  // assign item id
  nav_menu["item_"+i].num = i;
  
  nav_menu["item_"+i]._txt.text = navArray[i-1];
  nav_menu["item_"+i].hit_btn._width = nav_menu["item_"+i]._txt.textWidth+5;
  // Set original Color
  var c = new Color(nav_menu["item_"+i]);
  c.setRGB(BaseColor);
  
  // Set RollOver color state for all buttons
  nav_menu["item_"+i].onRollOver =function  () {
   var c = new Color(this);
   c.setRGB(RolloverColor);
  }
  
  // Set RollOut color state for all buttons
  nav_menu["item_"+i].onRollOut =nav_menu["item_"+i].onReleaseOutside = function  () {
   var c = new Color(this);
   c.setRGB(BaseColor);
  }
  
  // Set Click color state for all buttons
  nav_menu["item_"+i].onRelease = function  () {
   // call switch function
   switchActiveColor(this.num);
  }
  
  
 }
}

// navigation
function switchActiveColor(num) {
 // Set current selection
 currentSelection = num;
 // ALl buttons
 for (var i=1; i<=5; ++i) {
  nav_menu["item_"+i].enabled = true;
  var c = new Color(nav_menu["item_"+i]);
  c.setRGB(BaseColor);
  if (i==num) {
   nav_menu["item_"+i].enabled = false;
   c.setRGB(SelectedColor);
  }
 }
}


setupMenu();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值