今天研讨了一个做FLASH网站经常会用到的效果,即点击不同的按钮,主场景用来loadMovie的框框的X,Y,H,W值也随着变化。
演示效果动画:
点击这里下载源文件
次要代码如下:
stageWidth = 800;
stageHeight = 600;
wmodifier = 400;
hmodifier = 150;
bounce = 0.700000;
speed = 9;
expand = function (id){
this.destwidth = wmodifier;
this.poswidth = id._width;
this.velwidth = this.velwidth * bounce + (this.destwidth - this.poswidth) / speed;
id._width = id._width + Math.round(this.velwidth);
this.destheight = hmodifier;
this.posheight = id._height;
this.velheight = this.velheight * bounce + (this.destheight - this.posheight) / speed;
id._height = id._height + Math.round(this.velheight);
this.destx = (stageWidth - wmodifier) / 2;
this.posx = id._x;
this.velx = this.velx * bounce + (this.destx - this.posx) / speed;
id._x = id._x + Math.round(this.velx);
this.desty = (stageHeight - hmodifier) / 2;
this.posy = id._y;
this.vely = this.vely * bounce + (this.desty - this.posy) / speed;
id._y = id._y + Math.round(this.vely);
shadow._width = color_kuai._width + 20;
shadow._x = color_kuai._x - 10;
shadow._height = color_kuai._height + 20;
shadow._y = color_kuai._y - 10;
};
color_kuai.onEnterFrame = function (){
expand(this);
};
stop();
源文件里面有详细的说明。