一款漂亮的韩国导航条教程

来源:互联网 发布:opencv3编程入门 网盘 编辑:程序博客网 时间:2024/05/02 02:37

演示地址:http://www.flash8.net/bbs/UploadFile/2004-5/20045782132905.swf

分为两部分,一部分为准备工作,另一部分为代码~

准备工作:
1.新建一个名为item_BG的影片剪辑~
在item_BG中添加一个矩形块,大小大概就和按钮的大小差不多,具体自己调~
然后将item_BG该影片剪辑的链接名称命名为"mblock"
2.新建一个名为item_EN的影片剪辑~()
在item_EN中添加一个动态文本框,将实例名称命名为"itext",文本框位置大小自己调~
这里要注意的是在属性栏的右下方,有一个“字符...”按钮,点击可以看到字符选项~其中默认是无字符,也就是说什么字符都能显示~点击“指定范围”按钮后,可以在“包含此属性”下的输入框中输入字符或文字,只有这些文字或字符才能显示~
3.新建一个名为item_ZH的影片剪辑~
在item_EN中添加一个动态文本框,将实例名称命名为"itext",文本框位置大小自己调~
很多朋友都是在这里搞不懂,不明白为什么自己添加的文字不能够显示,看了上面第二段应该可以明白了~只需要把自己添加的文字加在“包含此属性”下的输入框中~
4.另外新建两个影片剪辑,分别为item_L和item_TOPLine~
item_L就是分割线,item_TOPLine则是文字上方的颜色条,大小位置自己调~
5.新建名为MenuItem的影片剪辑~
这里主要是把刚才做的各个影片剪辑排布好~
实例名分别如下:
item_TOPLine:topLine
item_L:mc_L
item_EN:mc_EN
item_ZH:mc_CH
并将MenuItem该影片剪辑的链接名称命名为"MenuItem"~
所有的准备工作的做好了,接下来添加代码~
回到主场景,在第一帧添加如下代码:


var drag = 0.1;
//震动参数
var flex = 0.7;
//震动参数
var menuEN = new Array("News", "Movie", "Music", "Game", "Net TV", "BBS", "Member");
//定义一个数组,调用相应的英文文字,你可以在这里添加或修改,当然不想要英文就把它删掉吧~
var menuZH = new Array("新闻频道", "电影频道", "音乐频道", "游戏频道", "网络电视", "网友论坛", "会员专区");
//定义一个数组,调用相应的中文文字,同上,记住这两个数组中的文字只能输入你指定范围的文字,否则无法显示~
var menuURL = new Array("http://www.cinkey.com:88", "#", "#", "#", "#", "#", "#");
//定义一个数组,调用相应的链接~
var menuColor = new Array(0xD808B8, 0x00A2FF, 0x96D302, 0xFFC600, 0xFF5400, 0x7908D8, 0x02D396);
//定义一个数组,调用相应的颜色值~
var mBlock = this.attachMovie("mblock", "mb", 0);
//将链接名称为mblock的影片剪辑附加到场景中来,并声明一个变量mBlock来指定它~
mBlock._y = 5;
//设定y坐标,y坐标始终是不变的
mBlock.goalX = -100;
mBlock.onEnterFrame = function() {
 this.Step = this.Step*flex+(this.goalX-this.px)*drag;
 this.px += this.Step;
 this._x = this.px;
 if (this.sOut && this._xscale<99.5) {
  this._xscale += (100-this._xscale)/8;
 }
 if (this.sIn && this._xscale>0.1) {
  this._xscale += -this._xscale/8;
 }
};
var MBColor = new Color(mBlock);
for (var i = 0; i<menuZH.length; i++) {
 var theItem = this.attachMovie("MenuItem", "Item"+i, i+10);
 theItem._x = i*84;
 theItem.mColor = menuColor[i];
 theItem.URL = menuURL[i];
 theItem.mc_ZH.itext.text = menuZH[i];
 theItem.mc_EN.itext.text = menuEN[i];
 theItem.mc_EN._alpha = 0;
 theItem.onEnterFrame = function() {
  if (this.fadeOut) {
   if (this.topLine._alpha<99.5) {
    this.topLine._alpha += (100-this.topLine._alpha)/8;
   }
   if (this.mc_EN._alpha<99.5) {
    this.mc_EN._alpha += (100-this.mc_EN._alpha)/8;
   }
   if (this.mc_ZH._xscale<130) {
    this.mc_ZH._xscale += 2;
    this.mc_ZH._yscale += 2;
   }
  }
  if (this.fadeIn) {
   if (this.mc_EN._alpha>0.5) {
    this.mc_EN._alpha += -this.mc_EN._alpha/8;
   }
   if (this.topLine._alpha>0.5) {
    this.topLine._alpha += -this.topLine._alpha/8;
   }
   if (this.mc_ZH._xscale>100) {
    this.mc_ZH._xscale -= 2;
    this.mc_ZH._yscale -= 2;
   }
  }
 };
 theItem.onRollOver = function() {
  mBlock.goalX = this._x+42;
  mBlock.sOut = true;
  mBlock.sIn = false;
  MBColor.setRGB(this.mColor);
  new Color(this.topLine).setRGB(this.mColor);
  //new Color(this.mc_ZH).setRGB(0xFFFFFF);
  this.fadeOut = true;
  this.fadeIn = false;
 };
 theItem.onRollOut = function() {
  mBlock.sOut = false;
  mBlock.sIn = true;
  //new Color(this.mc_ZH).setRGB(0x000000);
  this.fadeIn = true;
  this.fadeOut = false;
 };
 theItem.onRelease = function() {
  getURL(this.URL);
 };
}
stop();