# Getting the ratio right

**URL:** <https://forum.kirupa.com/t/getting-the-ratio-right/225519>\
**Category:** Uncategorized\
**Created:** [May 13, 2007, 4:48am UTC](https://forum.kirupa.com/t/getting-the-ratio-right/225519 "2007-05-13T04:48:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ninjacat](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@Ninjacat](https://forum.kirupa.com/u/Ninjacat)\
**Post date:** [May 13, 2007, 4:48am UTC](https://forum.kirupa.com/t/getting-the-ratio-right/225519/1 "2007-05-13T04:48:06Z")

</div>

I’m trying to set up a dragger that moves a bugger movieclip up and down. As this will be for a template I’m thinking of using a ratio and thus save some time updating.

The code I’m using is

> onClipEvent (load) {  
> \_y = \_root.box.\_y-\_root.box.\_height/2+\_height/2 ;  
> \_x = \_root.box.\_x ;  
> yold = \_y ;  
> ratio = \_root.content.\_height/\_root.box.\_height ;  
> }  
> onClipEvent (enterFrame) {  
> if (dragging) {  
> if((\_root.\_ymouse\>\_root.box.\_y-\_root.box.\_height/2)and (\_root.\_ymouse\<\_root.box.\_y+\_root.box.\_height/2)) {  
> \_y = \_root.\_ymouse ;  
> dxdrag = \_y - yold ;  
> yold = \_y ;  
> \_root.content.\_y -= ratio\*dxdrag ;  
> }  
> }  
> }

Where “content” is the big movieclip and “box” is the boundery for the slider.  
The problem I’m having is the “content” is moving up to high when the slider is at the end of the “box”. Is there a way to set a range within a mask for example.
