# Movieclip Onrollover?

**URL:** <https://forum.kirupa.com/t/movieclip-onrollover/111619>\
**Category:** Uncategorized\
**Created:** [May 29, 2004, 12:45am UTC](https://forum.kirupa.com/t/movieclip-onrollover/111619 "2004-05-29T00:45:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flashfile](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@Flashfile](https://forum.kirupa.com/u/Flashfile)\
**Post date:** [May 29, 2004, 12:45am UTC](https://forum.kirupa.com/t/movieclip-onrollover/111619/1 "2004-05-29T00:45:43Z")

</div>

Hi All,

Sorry guys I did not show up for long i was down, I have a movieclip and I want it to Vibrate on rollover. How do I do that?

Someone Help Fast Plz.

Thanks in Advance.

FlashFile :hair:

---

<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:** [May 29, 2004, 12:53am UTC](https://forum.kirupa.com/t/movieclip-onrollover/111619/2 "2004-05-29T00:53:23Z")

</div>

Put this on your movieclip

```auto

on(rollOver) {
	over = 1;
}
on(rollOut) {
	over = 0;
	this._x = originalX;
	this._y = originalY;
}
onClipEvent(load) {
	originalX = this._x;
	originalY = this._y;
}
onClipEvent(enterFrame) {
	if(over) {
		this._x += Math.random()*(.5 - -.5) + -.5;
		this._y += Math.random()*(.5 - -.5) + -.5;
	}
}

```

I can comment it out line by line for you if you don’t understand. To make it go faster, you need to use it with a higher frame rate, I tested it at 24 fps.

---

<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:** [May 29, 2004, 1:15am UTC](https://forum.kirupa.com/t/movieclip-onrollover/111619/3 "2004-05-29T01:15:10Z")

</div>

Hey Yeldarb

Thanx It really work as i wanted it but if u can I will like you to tell me what each of the lines of code do.  
plzzzzzzzzzz?

FlashFile

---

<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:** [May 29, 2004, 1:33am UTC](https://forum.kirupa.com/t/movieclip-onrollover/111619/4 "2004-05-29T01:33:54Z")

</div>

Yep, sure thing.

```auto

on(rollOver) {
	over = 1;
//This sets the variable "over" to 1 when you roll over the movieclip
}
on(rollOut) {
	over = 0;
//This sets the variable "over" to 0 when you roll off of the movieclip
	this._x = originalX;
//This sets the X position back to the original
	this._y = originalY;
//this sets the Y position back to the original
}
onClipEvent(load) {
	originalX = this._x;
//this saves the original X that will be recovered later
	originalY = this._y;
//this saves the original Y that will be recovered later
}
onClipEvent(enterFrame) {
	if(over) {
//This checks to see if "over" is true or false on every frame
		this._x += Math.random()*(.5 - -.5) + -.5;
//If it is, it moves the movieclip left or right a random amount between -.5 and .5
		this._y += Math.random()*(.5 - -.5) + -.5;
//If it is, it moves the movieclip up or down a random amount between -.5 and .5
	}
}

```

Pretty straight forward 🙂  
If you need any more help with it, I’d be glad to.

---

<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:** [May 29, 2004, 2:42am UTC](https://forum.kirupa.com/t/movieclip-onrollover/111619/5 "2004-05-29T02:42:19Z")

</div>

thanx,

Thank you very much i think i have to go and study this as much as I can so that I can do it any where any time.

Thank you very much

FlashFile

---

<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:** [May 29, 2004, 2:49am UTC](https://forum.kirupa.com/t/movieclip-onrollover/111619/6 "2004-05-29T02:49:30Z")

</div>

Yep, no problem. I wouldn’t study it too hard though, it’s not as efficient as it could be. The onClipEvent(enterFrame) uses too much CPU power. If you really wanted to make it more efficient, I think you could use functions to call the onClipEvent(enterFrame), but it would be a bit more complicated and I don’t know how much it would optimize it (if at all).

Keep practicing though, this stuff will come 🙂

---

<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:** [May 29, 2004, 2:58am UTC](https://forum.kirupa.com/t/movieclip-onrollover/111619/7 "2004-05-29T02:58:37Z")

</div>

ok,  
Thanks once more.
