// [flashAPI].mx resize // // it's part of [flashAPI] project // http://flashAPI.yestoall.com // // [03.01.30] nacho@yestoall.com /* methods : resizeTo(x,y,[speed],[interval]); -> resize movement to (x,y) absolute coordinates resizeBy(x,y,[speed],[interval]); -> resize movement to (x,y) relative coordinates resizeStop(); -> stop movement * in both cases speed are optional * by default speed=6 speed = numbers [2 - 20] -> 1 is fast, 20 is slow * by default interval=10 interval = miliseconds between movements events : onresize(x,y) -> in every loop of movement onresizeEnd() -> at the end of resize movement examples : mc1.resizeTo(100,100); -> resize to (100,100) absotule coordinates mc2.resizeBy(50,50,8); -> resize to (50,50) relative coordinates width speed=8 */ MovieClip.prototype.resizeTo = function(x,y,speed,interval) { if (this.resizeActive) clearInterval(this.resizeThread); this.resizeActive = true; this.resizeXend = (x!=null) ? x : this._width; this.resizeYend = (y!=null) ? y : this._height; this.resizeSpeed = speed || 6; this.resizeInterval = interval || 10; this.resizeThread = setInterval (this,"resizeLoop",this.resizeInterval); } MovieClip.prototype.resizeBy = function(x,y,speed,interval) { this.resizeTo(this._width+x,this._height+y,speed,interval); } MovieClip.prototype.resizeStop = function() { if (!this.resizeActive) return; this.resizeActive = false; clearInterval(this.resizeThread); } MovieClip.prototype.resizeLoop = function() { var xdif = this.resizeXend - this._width; var ydif = this.resizeYend - this._height; this._width += xdif / this.resizeSpeed; this._height += ydif / this.resizeSpeed; this.onresize(xdif/this.resizeSpeed, ydif/this.resizeSpeed); if (Math.abs(xdif)<1 && Math.abs(ydif)<1) { this._width = this.resizeXend; this._height = this.resizeYend; this.resizeStop(); this.onresizeEnd(); } }