# Constraining Movement \>function\_move?

**URL:** https://forum.kirupa.com/t/constraining-movement-function-move/290325
**Category:** Uncategorized
**Created:** [June 12, 2009, 6:15pm UTC](https://forum.kirupa.com/t/constraining-movement-function-move/290325 "2009-06-12T18:15:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![haider](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@haider](https://forum.kirupa.com/u/haider)
#### Post date: [June 12, 2009, 6:15pm UTC](https://forum.kirupa.com/t/constraining-movement-function-move/290325/1 "2009-06-12T18:15:25Z")

</div>

I have a split screen view with a large image above and a smaller image underneath.

There is a zoom window over the smaller image that when dragged around shows the larger image above it being moved at the same time (just that it’s bigger uptop)

[COLOR=Navy]\*\*anyways I can’t seem to constrain the movement of the smaller movie clip … right now you can just click and drag it all over the place … and I’ll like for it to stay dragable only over top of the smaller image…

The name of the movie clip is … lilfigure\*\*[/COLOR]

and here is the code in the root.

// The base\_mag\_factor is the correlation of the small picture to the big picture…  
\_root.base\_mag\_factor = 5;  
// The mag\_factor will change as scaling occurs  
\_root.mag\_factor = \_root.base\_mag\_factor;  
//Stop so that this doesn’t reset willy-nilly on us  
stop();

/\*  
This function scales the magnifying glass and the bigpicture  
It also helps to handle the centering effect on the zoom…  
Read the comments on how that happens  
\*/  
function scale\_mag (zoom\_perc,mag\_perc) {

```
// getting ready for later...to be able to center
start_width = _root.mag._width;
start_height = _root.mag._height;
//scale it all...
_root.figure._xscale = (zoom_perc);
_root.figure._yscale = (zoom_perc);
_root.mag._xscale = (mag_perc);
_root.mag._yscale = (mag_perc);
_root.mag_factor = (zoom_perc/100)*(_root.base_mag_factor);
_root.zoom_ind = zoom_perc; //updates the percentage viewer
// The other half keeps scaling in sync and centers the scaling
// Find out the width and height now
end_width = _root.mag._width;
end_height = _root.mag._height;
// Figure the difference in width and height (x and y)
x_change = start_width - end_width;
y_change = start_height - end_height;
//adjust by half the difference
_root.mag._x = _root.mag._x + x_change/2;
_root.mag._y = _root.mag._y + y_change/2;

```

}

/\*  
Moves the panel inside the viewing window…  
It moves opposite the magnifying glass.  
This function is also called when scaling occurs  
_/  
function move\_panel () {  
//trace (\_root.mag\_factor);  
\_root.figure.\_x = 0 -((\_root.mag.\_x-\_root.lilfigure.\_x)_\_root.mag\_factor);  
\_root.figure.\_y = 0 -((\_root.mag.\_y-\_root.lilfigure.\_y)\*\_root.mag\_factor);  
}

Thanks in advance.

Cheers
