# Scaling using as

**URL:** <https://forum.kirupa.com/t/scaling-using-as/13660>\
**Category:** Uncategorized\
**Created:** [February 16, 2003, 3:01pm UTC](https://forum.kirupa.com/t/scaling-using-as/13660 "2003-02-16T15:01:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimw00d](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jimw00d](https://forum.kirupa.com/u/jimw00d)\
**Post date:** [February 16, 2003, 3:01pm UTC](https://forum.kirupa.com/t/scaling-using-as/13660/1 "2003-02-16T15:01:41Z")

</div>

Hey,

If I drew a rectangle on stage using the api drawing methods and say the box was 100x50 in size, what method could I use to increase the size of the box over a period of time so that it appears to grow in size, or indeed shrink in size.

I understand I could simply use a for loop and then increase the width and height accordingly but how would I set the size of the rectangle that I would like the scaling to stop at.

cheers

Any help would be great.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 16, 2003, 3:40pm UTC](https://forum.kirupa.com/t/scaling-using-as/13660/2 "2003-02-16T15:40:24Z")

</div>

```auto
scale = function (instance, amount, endscale) {
	if (instance._xscale != endscale) {
		instance._xscale = instance._yscale += amount
		updateAfterEvent ()
	} else {
		clearInterval (scaleInterval)
	}
}

scaleInterval = setInterval (scale, milliseconds, instance, amount, endscale)

```

**milliseconds** number of milliseconds to wait between every execution  
**instance** instance name of the movie clip to scale  
**amount** percentage to scale the movie clip in each execution  
**endscale** final xscale and yscale value

example:

if your movie clip instance name is _rectangle_. you want to increase its scale by 10% each second and the final scale is 200%

```auto
scaleInterval = setInterval (scale, 1000, rectangle, 10, 200)

```

hope it helps 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 16, 2003, 11:25pm UTC](https://forum.kirupa.com/t/scaling-using-as/13660/3 "2003-02-16T23:25:13Z")

</div>

Careful with this because you won’t necessarily have instance.\_xscale == endscale at some point so it might not stop at all 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 16, 2003, 11:35pm UTC](https://forum.kirupa.com/t/scaling-using-as/13660/4 "2003-02-16T23:35:38Z")

</div>

```auto
scale = function (instance, amount, endscale) {
	if (instance._xscale **<** endscale) {
		instance._xscale = instance._yscale += amount
		updateAfterEvent ()
	} else {
		clearInterval (scaleInterval)
	}
}

scaleInterval = setInterval (scale, milliseconds, instance, amount, endscale)

```

happy ?? =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 17, 2003, 12:13am UTC](https://forum.kirupa.com/t/scaling-using-as/13660/5 "2003-02-17T00:13:37Z")

</div>

No: what if you want the clip to shrink? :beam: :beam:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 17, 2003, 12:25am UTC](https://forum.kirupa.com/t/scaling-using-as/13660/6 "2003-02-17T00:25:11Z")

</div>

you add a new variable to tell the function what to do 😛
