# Movieclip follow within btn

**URL:** https://forum.kirupa.com/t/movieclip-follow-within-btn/35092
**Category:** Uncategorized
**Created:** [November 10, 2003, 1:43pm UTC](https://forum.kirupa.com/t/movieclip-follow-within-btn/35092 "2003-11-10T13:43:20Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![barge](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@barge](https://forum.kirupa.com/u/barge)
#### Post date: [November 10, 2003, 1:43pm UTC](https://forum.kirupa.com/t/movieclip-follow-within-btn/35092/1 "2003-11-10T13:43:20Z")

</div>

I have been trying to get this movieclip to follow the cursor upon rollover of a btn. I tried to put the movie clip inside the button and add script directly to the mc, and it didn’t work. Thanks in advance.

---

<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:47pm UTC](https://forum.kirupa.com/t/movieclip-follow-within-btn/35092/2 "2003-11-10T13:47:34Z")

</div>

make it a variable

```auto

on(rollover) {
_root.follow = 1;
}
on(rollout) {
_root.follow = 0;

```

```auto

if(_root.follow == 1;) {
//follow the mouse
} else {
//don't follow the mouse
}

```

---

<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:58pm UTC](https://forum.kirupa.com/t/movieclip-follow-within-btn/35092/3 "2003-11-10T13:58:03Z")

</div>

Place this on the timeline in which your movieclip is in (if youwant it to be a button let me know, I’ll modify the script).

```auto

yourbutton.onRollOver = function(){
// delete this.onRollOver
// uncomment previous line if you don't want it to be able to be rolled over again
this.onMouseMove = function(){
this._x = _root._xmouse
this._y = _root._ymouse
}
}

```

---

<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:03pm UTC](https://forum.kirupa.com/t/movieclip-follow-within-btn/35092/4 "2003-11-10T14:03:49Z")

</div>

well the movie clip is inside a button, so i can’t add script to the timeline of the button, thats whats confusing.

---

<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:16pm UTC](https://forum.kirupa.com/t/movieclip-follow-within-btn/35092/5 "2003-11-10T14:16:02Z")

</div>

Ah I see. Why does the movieclip has to be inside the button ? Those are kinda hard to use.

---

<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:22pm UTC](https://forum.kirupa.com/t/movieclip-follow-within-btn/35092/6 "2003-11-10T14:22:28Z")

</div>

oh, my fault, i have gone over the tutorials on hover captions. Should I just have to add that script you supplied to the timeline? I will mess with it. Thanks so much.

---

<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:49pm UTC](https://forum.kirupa.com/t/movieclip-follow-within-btn/35092/7 "2003-11-10T14:49:03Z")

</div>

i can’t get it i will just work with the tutorial.
