This script is for creating a resizing bounce effect on a button press. I hav one box I’m using this for. I’m wondering if there is any way I could manipulate the script so that I could have multiple boxes using this script at once? Here is the AS.
//for box 1
// Set initial variables
stageWidth=800; // Can also use the Stage.width property
stageHeight=600; // Can also use the Stage.height property
wmodifier = 225;
hmodifier = 271;
/* .7 for decent bounce effect */
bouncefactor = .7;
/* 6 for nice speed */
speedfactor = 8;
expand = function (id) {
// colorSquare width
this.destwidth = wmodifier;
this.poswidth = id._width;
this.velwidth = this.velwidth*bouncefactor+(this.destwidth-this.poswidth)/speedfactor;
id._width += Math.round(this.velwidth);
// colorSquare height
this.destheight = hmodifier;
this.posheight = id._height;
this.velheight = this.velheight*bouncefactor+(this.destheight-this.posheight)/speedfactor;
id._height += Math.round(this.velheight);
// colorSquare x
this.destx = (stageWidth-wmodifier)/6; //starting position of the box
this.posx = id._x;
this.velx = this.velx*bouncefactor+(this.destx-this.posx)/speedfactor;
id._x += Math.round(this.velx);
// colorSquare y
this.desty = (stageHeight-hmodifier)/2;
this.posy = id._y;
this.vely = this.vely*bouncefactor+(this.desty-this.posy)/speedfactor;
id._y += Math.round(this.vely);
// shadow properties
shadow._width = (colorSquare._width+20);
shadow._x = (colorSquare._x-10);
shadow._height = (colorSquare._height+20);
shadow._y = (colorSquare._y-10);
};
colorSquare.onEnterFrame = function() {
expand(this);
};