# Scale out from center

**URL:** <https://forum.kirupa.com/t/scale-out-from-center/18994>\
**Category:** Uncategorized\
**Created:** [April 23, 2003, 9:51am UTC](https://forum.kirupa.com/t/scale-out-from-center/18994 "2003-04-23T09:51:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweepah](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@sweepah](https://forum.kirupa.com/u/sweepah)\
**Post date:** [April 23, 2003, 9:51am UTC](https://forum.kirupa.com/t/scale-out-from-center/18994/1 "2003-04-23T09:51:45Z")

</div>

I actually spend some time searching how it could be done, its quite simple but maybe it will be some use for someone and since I have been lurking around for a while it seemed like a good way to say hi:P. It makes up for the fact that flash scales from the registration point.

[AS] MovieClip.prototype.centreScale = function(speed) {  
this.\_x += this.\_width/2;  
this.\_y += this.\_height/2;  
// get the necessary properties  
var steps = 100/speed;  
var xrate = this.\_width/2/steps;  
var yrate = this.\_height/2/steps;  
// scale to 0  
this.\_xscale = 0;  
this.\_yscale = 0;  
if (this.\_xscale\<100) {  
// scale out  
this.onEnterFrame = function() {  
if (this.\_xscale\<100) {  
with (this) {  
\_xscale += speed;  
\_x -= xrate;  
\_yscale += speed;  
\_y -= yrate;  
}  
}  
};  
} else {  
delete this.onEnterFrame;  
}  
}; [/AS]

Usage:

[AS] \_root.onLoad = function() {  
// draw your object  
object.centreScale(2);  
} [/AS]
