# Zoom onClipEvent (mouseDown) issue

**URL:** <https://forum.kirupa.com/t/zoom-onclipevent-mousedown-issue/158164>\
**Category:** Uncategorized\
**Created:** [August 7, 2005, 8:21pm UTC](https://forum.kirupa.com/t/zoom-onclipevent-mousedown-issue/158164 "2005-08-07T20:21:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eruditorium](https://avatars.discourse-cdn.com/v4/letter/e/f0a364/32.png) [@Eruditorium](https://forum.kirupa.com/u/Eruditorium)\
**Post date:** [August 7, 2005, 8:21pm UTC](https://forum.kirupa.com/t/zoom-onclipevent-mousedown-issue/158164/1 "2005-08-07T20:21:01Z")

</div>

[font=Times New Roman][size=3]Please can anyone with advanced knowledge of Actionscript please help me with my code (shown below) in respect to a requirement for zooming?[/size][/font]

```
 [font=Times New Roman][size=3]I'm creating a flash animation in which I'd like to 'zoom' in and out of a movie clip when the mouse is held. I only want to zoom into the movieclip if the mouse is being held down and if released the movie should zoom back out. [/size][/font]

 [font=Times New Roman][size=3]I'm using someone else's code (shown below) which gives me the ability to zoom into a point where the cursor is clicked. If the mouse is clicked a second time it returns back to original resolution. The code uses onClipEvent (mouseDown) rather than this.hitTest to ensure the zoom goes to the area the cursor is positioned.[/size][/font]

 [font=Times New Roman][size=3]Is it possible to adapt this code so rather than just zooming to a set magnification and stopping, it zooms only if the mouse is held down, and returns to original resolution on the mouse is released?[/size][/font]

 [font=Times New Roman][size=3]The .fla for the code I am using is at:[/size][/font]

```

[font=Times New Roman][size=3][http://www.flashkit.com/movies/Effects/Other/Auto\_zoo-T\_Norman-6578/index.php](http://www.flashkit.com/movies/Effects/Other/Auto_zoo-T_Norman-6578/index.php)[/size][/font]

```
 [font=Times New Roman][size=3]many thanks in advance..[/size][/font]

 [font=Times New Roman][size=3]actions assigned to cursor:[/size][/font]

 [font=Times New Roman][size=3]*/note: "zoom_this" is the instance name for the movie being zoomed.)*/[/size][/font]

```

[font=Times New Roman][size=3]onClipEvent (mouseDown) {[/size][/font]

[font=Times New Roman][size=3] if (i\>0) {[/size][/font]

[font=Times New Roman][size=3] return;[/size][/font]

[font=Times New Roman][size=3] }[/size][/font]

```
 [font=Times New Roman][size=3] zoom = true;[/size][/font]

```

[font=Times New Roman][size=3] dir == 1 ? (dir=-1) : (dir=1);[/size][/font]

[font=Times New Roman][size=3] if (dir == 1) {[/size][/font]

[font=Times New Roman][size=3] pt = {x:\_root.zoom\_this.\_xmouse, y:\_root.zoom\_this.\_ymouse};[/size][/font]

[font=Times New Roman][size=3] }[/size][/font]

```
 [font=Times New Roman][size=3]onClipEvent (enterFrame) {[/size][/font]

```

[font=Times New Roman][size=3] if (!zoom) {[/size][/font]

[font=Times New Roman][size=3] return;[/size][/font]

[font=Times New Roman][size=3] }[/size][/font]

[font=Times New Roman][size=3] \_root.zoom\_this.\_xscale += dir_i_100/8;[/size][/font]

[font=Times New Roman][size=3] \_root.zoom\_this.\_yscale += dir_i_100/8;[/size][/font]

[font=Times New Roman][size=3] var pt2 = {x:pt.x, y:pt.y};[/size][/font]

[font=Times New Roman][size=3] \_root.zoom\_this.localToGlobal(pt2);[/size][/font]

[font=Times New Roman][size=3] \_root.zoom\_this.\_x -= (pt2.x-pt.x);[/size][/font]

[font=Times New Roman][size=3] \_root.zoom\_this.\_y -= (pt2.y-pt.y);[/size][/font]

[font=Times New Roman][size=3] i++;[/size][/font]

[font=Times New Roman][size=3] if (i == 10) {[/size][/font]

[font=Times New Roman][size=3] zoom = false;[/size][/font]

[font=Times New Roman][size=3] i = 0;[/size][/font]

[font=Times New Roman][size=3] }[/size][/font]

[font=Times New Roman][size=3]}[/size][/font]

[font=Times New Roman][size=3]Thanks[/size][/font]

[font=Times New Roman][size=3][font=&quot][xstasis](http://www.xstasis.net/)[/font][/size][/font]
