# Mouseover scaling

**URL:** <https://forum.kirupa.com/t/mouseover-scaling/34946>\
**Category:** Uncategorized\
**Created:** [November 8, 2003, 5:12am UTC](https://forum.kirupa.com/t/mouseover-scaling/34946 "2003-11-08T05:12:21Z")\
**Posts on this page:** 9\
**Page:** 2

<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:** [November 10, 2003, 1:05am UTC](https://forum.kirupa.com/t/mouseover-scaling/34946/21 "2003-11-10T01:05:05Z")

</div>

It worked for me (see modified “resizemore.fla” above). It has the OnRollOver and OnRollOffs to control the look of the button, just add an OnPress to make it do something…

---

<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:** [November 10, 2003, 2:03am UTC](https://forum.kirupa.com/t/mouseover-scaling/34946/22 "2003-11-10T02:03:11Z")

</div>

as a button inside a movie clip that has the roll over scale script applied to it?

the MC inside actin as a button doesn’t work do you know why?

---

<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:** [November 10, 2003, 8:03am UTC](https://forum.kirupa.com/t/mouseover-scaling/34946/23 "2003-11-10T08:03:51Z")

</div>

> \*Originally posted by Kay \*  
> \*\*with movie clips acting as buttons ☹ anyone know a way around this? \*\*

Lol, yes it does 😛 I even tested it with a button movieclip.

---

<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:** [November 10, 2003, 8:06am UTC](https://forum.kirupa.com/t/mouseover-scaling/34946/24 "2003-11-10T08:06:19Z")

</div>

> \*Originally posted by Kay \*  
> \*\*as a button inside a movie clip that has the roll over scale script applied to it?

the MC inside actin as a button doesn’t work do you know why? \*\*

That’s because when you rollOver the host movieclip, you’re already rolling over that causing the button laying underneath not to work anymore. You can solve this by using hitTest in an onEnterFrame handler to check if the mouse is rolling over instead of using the onRollOver handler.

---

<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:** [November 10, 2003, 8:27pm UTC](https://forum.kirupa.com/t/mouseover-scaling/34946/25 "2003-11-10T20:27:01Z")

</div>

would the script look something like this? (it doesn’t work)

MovieClip.prototype.resizeTo = function(to) {  
this.onEnterFrame = function() {  
this.\_xscale = this.\_yscale=to-(to-this.\_xscale)/1.2;  
this.\_xscale\>to-1 && this.\_xscale\<to+1 ? delete this.onEnterFrame : null;  
};  
};

onClipEvent (enterFrame){  
if (flash.hitTest( \_root.\_xmouse, \_root.\_ymouse, true)){  
flash.onRollOut = function() {  
this.resizeTo(100);}  
else  
flash.onRollOut = function() {  
this.resizeTo(70);  
};

```
	}

```

}:block:

---

<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:** [November 10, 2003, 8:43pm UTC](https://forum.kirupa.com/t/mouseover-scaling/34946/26 "2003-11-10T20:43:11Z")

</div>

The code is very simple in this case, but it takes more processor power:

```auto

mc.onEnterFrame = function() {
	if (this.hitTest(_root._xmouse, _root._ymouse)) {
		this._xscale = this._yscale=150-(150-this._xscale)/1.2;
	} else {
		this._xscale = this._yscale=100-(100-this._xscale)/1.2;
	}
};

```

And, if those are the only actions you’re gonna use, it can even be simplified to

```auto

mc.onEnterFrame = function() {
this.hitTest(_root._xmouse, _root._ymouse) ? this._xscale = this._yscale=150-(150-this._xscale)/1.2 : this._xscale = this._yscale=100-(100-this._xscale)/1.2;
};

```

Might look a bit complicated, but it’s exactly the same, it only uses the tertiary operator:

condition ? action\_if\_true : actions\_if\_false

---

<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:** [November 10, 2003, 8:46pm UTC](https://forum.kirupa.com/t/mouseover-scaling/34946/27 "2003-11-10T20:46:17Z")

</div>

try this:

[AS]onClipEvent(enterFrame){  
if (this.hitTest(\_root.\_xmouse, \_root.\_ymouse)) {  
this.resizeTo(100);  
} else {  
this.resizeTo(70);  
}  
}[/AS]

scotty;)  
edit/Voets is too quick for me(-:

---

<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:** [November 10, 2003, 9:57pm UTC](https://forum.kirupa.com/t/mouseover-scaling/34946/28 "2003-11-10T21:57:44Z")

</div>

got it working 🙂

thanks again for having patience and helping me out:thumb:

---

<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:** [November 11, 2003, 9:53am UTC](https://forum.kirupa.com/t/mouseover-scaling/34946/29 "2003-11-11T09:53:39Z")

</div>

No problem 🙂

[Previous page](https://forum.kirupa.com/t/mouseover-scaling/34946.md?page=1)
