关于一个网站FLASH导航条的制作

博客给出一段Flash代码,用于说明问题和解决问题。代码中定义了震动参数,计算滑块移动步长并累加,实现影片剪辑的移动。同时,为多个按钮设置了鼠标悬停和移出事件,控制影片剪辑的位置和缩放功能。

http://shineday.nease.net/

这里的代码是抄袭过来的,根本是为了说明问题和解决问题:)

var drag =0.1;
//震动参数
var flex =0.7;
//震动参数
mc._y =20;
mc.goalX =10;  //装入动画后影片剪辑(也就是滑块)首先出现的位置
mc.onEnterFrame = function() {
 
 this.Step =this.Step*flex+(this.goalX-this.px)*drag; //计算滑块移动步长的公式
 this.px+=this.Step;  //将步长累加,个人认为这个很重要,相当于一个循环,以本次移动步长为基准,进行下次累加
 this._x =this.px; //使影片剪辑的X坐标轴等于
 
 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;
  
 }
};

////The First Button Events

b1.onRollOver = function() {
 mc.goalX =this._x;   //将按钮的X坐标值赋给影片剪辑的初始位置,也就是说,下次移动以这次的位置为原点这里根据按  钮和影片剪辑的大小而定,若按钮比影片剪辑小,相应的加上一些数值以作调节
  mc.sOut = true;       /*这里是把一个BOOBLE值返回给调用它的函数,如下:
                                     if (this.sOut && this._xscale<99.5),以控制整个影片剪辑的缩放功能*/
  mc.sIn = false;
  this.fadeOut = true;
  this.fadeIn = false;
 };
 b1.onRollOut = function() {
  mc.sOut = false;
  mc.sIn = true;
  this.fadeIn = true;
  this.fadeOut = false;
 };
 
//The second Button Events
 b2.onRollOver = function() {
  mc.goalX =this._x;
  mc.sOut = true;
  mc.sIn = false;
  this.fadeOut = true;
  this.fadeIn = false;
 };
 b2.onRollOut = function() {
  mc.sOut = false;
  mc.sIn = true;
  this.fadeIn = true;
  this.fadeOut = false;
 };
 //The Third Button Events

b3.onRollOver = function() {
  mc.goalX =this._x;
  mc.sOut = true;
  mc.sIn = false;
  this.fadeOut = true;
  this.fadeIn = false;
 };
 b3.onRollOut = function() {
  mc.sOut = false;
  mc.sIn = true;
  this.fadeIn = true;
  this.fadeOut = false;
 };
 
 
 //The Fourth Button Events
 b4.onRollOver = function() {
  mc.goalX =this._x;
  mc.sOut = true;
  mc.sIn = false;
  this.fadeOut = true;
  this.fadeIn = false;
 };
 b4.onRollOut = function() {
  mc.sOut = false;
  mc.sIn = true;
  this.fadeIn = true;
  this.fadeOut = false;
 };
 
 //The Fifth Button Events
 
 b5.onRollOver = function() {
  mc.goalX =this._x;
  //trace(mc.goalX);
  mc.sOut = true;
  mc.sIn = false;
  
  this.fadeOut = true;
  this.fadeIn = false;
 };
 b5.onRollOut = function() {
  mc.sOut = false;
  mc.sIn = true;
  this.fadeIn = true;
  this.fadeOut = false;
 };

stop();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值