# How do I zoom in and out using Actionscript?

**URL:** <https://forum.kirupa.com/t/how-do-i-zoom-in-and-out-using-actionscript/65071>\
**Category:** flash\
**Created:** [September 22, 2004, 8:06pm UTC](https://forum.kirupa.com/t/how-do-i-zoom-in-and-out-using-actionscript/65071 "2004-09-22T20:06:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OM2](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@OM2](https://forum.kirupa.com/u/OM2)\
**Post date:** [September 22, 2004, 8:06pm UTC](https://forum.kirupa.com/t/how-do-i-zoom-in-and-out-using-actionscript/65071/1 "2004-09-22T20:06:43Z")

</div>

How do I zoom in and out using Actionscript?  
I have the following code to move an object around:

```auto
onClipEvent(load)
 {
     speed = 10;
     speedx = speedy = speed;
     targetx = this._x;
     targety = this._y;
 }
 onClipEvent(enterFrame)
 {
     _x += (targetx - _x)/speedx;
     _y += (targety - _y)/speedy;
 }

```

What I do is change the values of targetx and targety.

What I want to do is move the object and then zoom in or out.

So, I need to know:

1. How to zoom in and out usng Actionscript.
2. AND I need to know how I can do this at the END of the above animation?

Any help would be appreciated.

Thanks.

OM

---

<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:** [September 23, 2004, 7:58am UTC](https://forum.kirupa.com/t/how-do-i-zoom-in-and-out-using-actionscript/65071/2 "2004-09-23T07:58:04Z")

</div>

the zooming is not a real zoom. You practically need to scale your movie up.

```auto

onClipEvent(load)
 {
     speed = 10;
     speedx = speedy = speed;
     zoomx = 200;
     zoomy = 200;
     targetx = this._x;
     targety = this._y;
 }
 onClipEvent(enterFrame)
 {
     _x += (targetx - _x)/speed;
     _y += (targety - _y)/speed;
     if (Math.Abs(targetx-_x) <10 || Math.Abs(targety-_y)<10) {
     _xscale += (zoomx - _xscale)/speed;
     _yscale += (zoomy - _yscale)/speed;
     }
 }

```

Try the code above… I haven’t tested because I don’t have flash installed this days… Tell me how it works.
