# Set limit on zoom variable

**URL:** https://forum.kirupa.com/t/set-limit-on-zoom-variable/50508
**Category:** flash
**Created:** [May 3, 2004, 8:51pm UTC](https://forum.kirupa.com/t/set-limit-on-zoom-variable/50508 "2004-05-03T20:51:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![darrengeraghty](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@darrengeraghty](https://forum.kirupa.com/u/darrengeraghty)
#### Post date: [May 3, 2004, 8:51pm UTC](https://forum.kirupa.com/t/set-limit-on-zoom-variable/50508/1 "2004-05-03T20:51:56Z")

</div>

Whazzup;  
Im stuck on this and need an “Action Script Hero”  
to solve the prob…  
Ive got this zoomable map working pretty well  
but it keeps zooming out (ie. it dont stop!)  
so I need to set a variable that limits the zooming out of  
the map to a certain value like 200 and then pauses or  
stops the movie clip.This would need to be set on  
the rollover function see below.Does anybody know  
a easy way of doing this!

on (rollOver) {  
zoomMC.tzoomc=2;  
}  
on (rollOut, releaseOutside) {  
zoomMC.tzoomc=0;  
}

Im pulling my hair out ovr this!! Here is a link to the  
fla file…

[http://home.ripway.com/2004-3/80050/zoom\_map.zip](http://home.ripway.com/2004-3/80050/zoom_map.zip)

Any help appreciated!!

---

<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: [May 4, 2004, 2:59pm UTC](https://forum.kirupa.com/t/set-limit-on-zoom-variable/50508/2 "2004-05-04T14:59:49Z")

</div>

Cheers loon!  
I tried an if statement but it doesnt trigger the  
else value if a user holds down the mouse,  
I couldnt attach an onEvent either bcos  
im using buttons…  
So does any bright spark have a solution for this prob!!  
see the fla below…

on(press) {  
if (zoomMC.tzoom \<= 140){  
zoomMC.tzoomc=0;  
}  
else{  
zoomMC.tzoomc=-2;  
}

}

on (release, releaseOutside) {  
\_level0.host.zoomMC.tzoomc=0;  
}

---

<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: [May 4, 2004, 3:17pm UTC](https://forum.kirupa.com/t/set-limit-on-zoom-variable/50508/3 "2004-05-04T15:17:19Z")

</div>

Well I’m not really sure if this is what you are going for but I changed your on enter frame to:

```auto

onClipEvent (enterFrame) {
	tzoom += tzoomc;
	_xscale = _yscale=_yscale+speed*(tzoom-_yscale);
	if (_xscale>400) {
		tzoomc = -2;
	} else if (_xscale<140) {
		tzoomc = 0;
	}
	trace(_xscale)
}

```

As you can see by the trace when the scale gets to be over 400 (and it will go over because of the easing) then it starts to zoom out automatically. You can’t put the code on the rollover because you have repeatedly roll on and off the button to get it to work, which I assume you don’t want.

Hope this helps! :hr:

_edit_ You’ll have to play with the numbers to get it where you want it but you can hopefully get the idea of how it works.

---

<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: [May 4, 2004, 3:24pm UTC](https://forum.kirupa.com/t/set-limit-on-zoom-variable/50508/4 "2004-05-04T15:24:35Z")

</div>

_@#&@!^$&^# Microsoft! I just wrote this whole long response and motherf_\*\*ing IE ate it! Argh! Wish we could use Mozilla at work ☹

I’ll try to rewrite in a minute when I’ve calmed down . . .

---

<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: [May 4, 2004, 3:40pm UTC](https://forum.kirupa.com/t/set-limit-on-zoom-variable/50508/5 "2004-05-04T15:40:07Z")

</div>

Ill wait ‘patiently’ lunatic!  
tanx in advance for allyer time.  
I tried puttin yer onClipEvent in my fla but dacontrol panel  
wouldnt work then…  
By the way this swf is being loaded into another swf  
hence the level0.host. addressing…

---

<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: [May 4, 2004, 4:00pm UTC](https://forum.kirupa.com/t/set-limit-on-zoom-variable/50508/6 "2004-05-04T16:00:52Z")

</div>

Well, I messed with it for awhile and couldn’t make it stop. ☹ I have to go to a meeting now but will try again when I get back. Seems like there should be a way to delete the on enter frame once the max or min scales have been reached but I think the on rollover function of the buttons is messing with that. I’ll try again later.
