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();

|