# Aesthetic tweening 'roll offs'

**URL:** https://forum.kirupa.com/t/aesthetic-tweening-roll-offs/60371
**Category:** flash
**Created:** [August 9, 2004, 11:32am UTC](https://forum.kirupa.com/t/aesthetic-tweening-roll-offs/60371 "2004-08-09T11:32:42Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![cudos](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@cudos](https://forum.kirupa.com/u/cudos)
#### Post date: [August 9, 2004, 11:32am UTC](https://forum.kirupa.com/t/aesthetic-tweening-roll-offs/60371/1 "2004-08-09T11:32:42Z")

</div>

hiii everybody,

bear with me on this one…

The best way to explain my problem is to describe what i am trying to do. I have an image in my flash movie which will expand on a rollover. On the rollout, i want the image to contract back in. However, if the mouse cursor is ‘rolled out’ before the image has fully expanded, i want the image to shrink back in from the size it is currently at. (so if the picture is only half expanded, it will contract from that half size) I presume that this cannot happen using the functions of flash and must be scripted.

I have tried to search for a solution, but its hard to think of keywords for this problem, and so i have had to post this.

if anyone could either direct me to a tutorial, or give me some sort of hint as to how to go about this, it would be much appriciated.

thankyou in advance for any replies

Cudos

---

<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: [August 9, 2004, 6:16pm UTC](https://forum.kirupa.com/t/aesthetic-tweening-roll-offs/60371/2 "2004-08-09T18:16:21Z")

</div>

This is probably best accomplished with actionscript to expand it… something like:

```auto

setInterval(buttonExpand, 20, myButton1);
function buttonExpand(button){
if(button.hitTest(_xmouse, _ymouse, true) && button._xscale<200){
button._xscale += 10;
button._yscale += 10;
}
if(!button.hitTest(_xmouse, _ymouse, true) && button._xscale>100){
button._xscale -= 10;
button._yscale -= 10;
}
}

```

This will expand/contract the mc “myButton1”, I havent tested it though.

Edit:  
Here is a version that makes it easy to add multiple buttons:

```auto

buttons = new Array(myButton1, meep);
for(i=0;i<buttons.length;i++){
 setInterval(buttonExpand, 10, buttons*);
}
//setInterval(buttonExpand, 1, myButton1);
function buttonExpand(button:MovieClip) {
 if (button.hitTest(_xmouse, _ymouse, true) && button._xscale<200) {
  button._xscale += 1;
  button._yscale += 1;
 }
 if (!button.hitTest(_xmouse, _ymouse, true) && button._xscale>100) {
  button._xscale -= 1;
  button._yscale -= 1;
 }
}

```

Just edit the “buttons” array :).

---

<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: [August 11, 2004, 4:25pm UTC](https://forum.kirupa.com/t/aesthetic-tweening-roll-offs/60371/3 "2004-08-11T16:25:56Z")

</div>

cheers dunga, if you ever read this again!!!

---

<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: [August 11, 2004, 4:29pm UTC](https://forum.kirupa.com/t/aesthetic-tweening-roll-offs/60371/4 "2004-08-11T16:29:15Z")

</div>

That’s a bit complicated… Just use a simple hit test…

```auto
onClipEvent (enterFrame) {
	if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
		this.nextFrame();
	} else {
		this.prevFrame();
	}
}

```

Edit: That is, if you have actual frames for the button movement… If it’s a movieclip with tweens, or such.

---

<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: [August 11, 2004, 5:12pm UTC](https://forum.kirupa.com/t/aesthetic-tweening-roll-offs/60371/5 "2004-08-11T17:12:37Z")

</div>

cheers morse, that one makes life a little easier.

---

<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: [August 11, 2004, 7:30pm UTC](https://forum.kirupa.com/t/aesthetic-tweening-roll-offs/60371/6 "2004-08-11T19:30:42Z")

</div>

> [@cudos](#):
>
> cheers dunga, if you ever read this again!!!

Thanks, glad to help :thumb: And yes, my second example is complicated, but it saves coding in the long run- just one thing to add for a new button. Frames work well too, if you want a more customized animation.
