# Code to move zoom slider, remotely

**URL:** https://forum.kirupa.com/t/code-to-move-zoom-slider-remotely/311577
**Category:** flash
**Created:** [July 10, 2010, 6:17pm UTC](https://forum.kirupa.com/t/code-to-move-zoom-slider-remotely/311577 "2010-07-10T18:17:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rserge](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@rserge](https://forum.kirupa.com/u/rserge)
#### Post date: [July 10, 2010, 6:17pm UTC](https://forum.kirupa.com/t/code-to-move-zoom-slider-remotely/311577/1 "2010-07-10T18:17:23Z")

</div>

Hello,  
I have zoom code here

```auto

onClipEvent(load){

	scrollMin = _root.range._x+_root.range._width // minimum _x value possiible for scrollbar
	scrollMax = _root.range._x // maximum _x value possiible for scrollbar

	lowestScale = 50 // lowest desired scale of map in %
	highestScale = 200 // highest desired scale of map in %

	_x = scrollMin + (scrollMax - scrollMin)/1.5 //starting point

	scaleFactor = Math.pow(highestScale/lowestScale,1/(scrollMax-scrollMin)) // variable for SetScale
	function SetScale(){
		// calculates scale and sets it
		_root.scale = _root.map_mc._xscale = _root.map_mc._yscale = lowestScale * Math.pow(scaleFactor,(scrollMax-_x))
	}
	SetScale()
}
onClipEvent(mouseMove){
	if (dragging){
		_x = Math.min(Math.max(_parent._xmouse,scrollMax),scrollMin)
		SetScale()
		updateAfterEvent();
	}
}

```

When the file loads, zoom is at 75%. When the buttons in the code below are pressed I need the slider to move to 100%.

```auto

stopAllMCs = function(){
	_root.map_mc.site39_mc.gotoAndStop(1);
	_root.map_mc.site40_mc.gotoAndStop(1);
}
_root.srchMC.dataMC.site1_btn.onPress = function(){
	stopAllMCs()
	_root.map_mc.site39_mc.play();
	_root.srchMC._visible=false;
}
_root.srchMC.dataMC.site2_btn.onPress = function(){
	stopAllMCs();
	_root.map_mc.site40_mc.play();
	_root.srchMC._visible = false;
}

```

Looking at the code I thought maybe just attaching one line in the zoom code to each button in the frame…and change it…  
\_x = scrollMin + (scrollMax - scrollMin)/1.5 //starting point  
to…  
\_x = scrollMin + (scrollMax - scrollMin)/2 //which is the point associated with 100%, but how would I assign this to the button?

Do I have to copy and paste all of the slider code into the frame where my btns are? \_root.srchMC.dataMC.site1\_btn.onPress…  
Thanks.

To see this in action go to…  
[http://www.sergemedia.net/ds2/map/lakemap.html](http://www.sergemedia.net/ds2/map/lakemap.html)  
Click on search button on stage. Click on first Homesite in list. It activates a blue polygon on map. I need slider on zoom to move to 100%.
