# Scaling relative to mouse position

**URL:** <https://forum.kirupa.com/t/scaling-relative-to-mouse-position/102166>\
**Category:** Uncategorized\
**Created:** [February 20, 2004, 1:03pm UTC](https://forum.kirupa.com/t/scaling-relative-to-mouse-position/102166 "2004-02-20T13:03:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhunki](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@mhunki](https://forum.kirupa.com/u/mhunki)\
**Post date:** [February 20, 2004, 1:03pm UTC](https://forum.kirupa.com/t/scaling-relative-to-mouse-position/102166/1 "2004-02-20T13:03:45Z")

</div>

My actionscripting must be improving because I know the basics of this, just need a little help.

I have a dragable movie clip that on release I want to scale, depending on the mouse position, the further the mouse up the screen (y) then the smaller the clip scales on release.

Any help would be, as usual, appreciated.

Thanks folks

---

<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:** [February 20, 2004, 2:02pm UTC](https://forum.kirupa.com/t/scaling-relative-to-mouse-position/102166/2 "2004-02-20T14:02:44Z")

</div>

Maybe something like that, it prolly needs ajustments…

[AS]  
yourbutton.onRelease = function(){  
myMousey = \_root.\_mousey;  
pourcent = myMousey\*100/Stage.Height  
yourMC.\_xscale = yourMC.\_yscale = pourcent}  
[/AS]

---

<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:** [February 20, 2004, 2:18pm UTC](https://forum.kirupa.com/t/scaling-relative-to-mouse-position/102166/3 "2004-02-20T14:18:54Z")

</div>

Thanks, I’ll give that a try and let you know how I get on.

---

<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:** [February 20, 2004, 3:06pm UTC](https://forum.kirupa.com/t/scaling-relative-to-mouse-position/102166/4 "2004-02-20T15:06:58Z")

</div>

Nope. On release my movie clip disappears. I’ll have a closer look.

Is there a way of creating areas of scale as the mouse moves, ie: if the mouse is in a certain area, on release the clip scales to say 50%, if the mouse is in another area then it scales to 40%??

---

<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:** [February 20, 2004, 3:16pm UTC](https://forum.kirupa.com/t/scaling-relative-to-mouse-position/102166/5 "2004-02-20T15:16:47Z")

</div>

Little adjustment on Uli’s code  
[AS]yourbutton.onRelease = function() {  
myMousey = \_root.\_ymouse;  
pourcent = myMousey\*100/Stage.height;  
yourMC.\_xscale = yourMC.\_yscale=pourcent;  
};  
[/AS]

scotty(-:

---

<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:** [February 20, 2004, 4:08pm UTC](https://forum.kirupa.com/t/scaling-relative-to-mouse-position/102166/6 "2004-02-20T16:08:07Z")

</div>

Currently I’m just using something like this.

on (release) {  
stopDrag();  
trace(\_root.revolve.\_y);  
if (this.\_y \<= 195){  
this.\_yscale = 95;  
this.\_xscale = 95;

which seems to work well.

---

<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:** [February 20, 2004, 4:29pm UTC](https://forum.kirupa.com/t/scaling-relative-to-mouse-position/102166/7 "2004-02-20T16:29:54Z")

</div>

Yep, there are many ways of doing it:)

scotty(-:
