# Should be simple... but it is NOT!

**URL:** https://forum.kirupa.com/t/should-be-simple-but-it-is-not/9762
**Category:** Uncategorized
**Created:** [December 18, 2002, 1:42am UTC](https://forum.kirupa.com/t/should-be-simple-but-it-is-not/9762 "2002-12-18T01:42:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![buddylee](https://avatars.discourse-cdn.com/v4/letter/b/e5b9ba/32.png) [@buddylee](https://forum.kirupa.com/u/buddylee)
#### Post date: [December 18, 2002, 1:42am UTC](https://forum.kirupa.com/t/should-be-simple-but-it-is-not/9762/1 "2002-12-18T01:42:42Z")

</div>

I have written this very simple code that should work, but it won’t! Here is the deal. I have 2 boxes. 1 red and one blue. They are both MC. Now when you roll over the red box, the blue box should begin to start to follow your mouse. When you roll out of the red box, the blue box will stop following you. Everything works, but the box still follow even after rollOut. Please help. Here is what I did…

on the red box…

```auto
on (rollOver){
_root.follow = 1;
}

on (rollOut){
_root.follow = 0;
}

on the blue box....

onClipEvent(enterFrame){
if (_root.follow == 1){
startDrag(_root.dragger, true, 200, 200, 600, 200);
}
if (_root.follow == 0){
stopDrag();
}
}

```

---

<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: [December 18, 2002, 2:24am UTC](https://forum.kirupa.com/t/should-be-simple-but-it-is-not/9762/2 "2002-12-18T02:24:01Z")

</div>

why don’t you do this instead…on the movieClip that you want to follow put this code:

```php

onClipEvent(enterFrame){
     if(_root._ymouse >= MaxYValue && _root._ymouse <= MinYValue){
          if(_root._xmouse >= MaxXValue && _root._xmouse <= MinXValue){
                this._x = _root._xmouse
                this._y = _root._ymouse
          } 
     }
}

```

Something like that should work. Just change the Max and Min X and Y values to the correct numbers…

---

<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: [December 18, 2002, 6:59am UTC](https://forum.kirupa.com/t/should-be-simple-but-it-is-not/9762/3 "2002-12-18T06:59:07Z")

</div>

you’re right about the code though. It certainly looks like it should work… and you say it does, but doesn’t stop working. which is more glitchy than signs of incorrect programming.

just for \*\*\*\*s and giggles, check out your whole movie to make sure that you do not have two movie clips with the same instance name. I often encounter problems like that when I double up on names.

---

<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: [December 18, 2002, 7:10am UTC](https://forum.kirupa.com/t/should-be-simple-but-it-is-not/9762/4 "2002-12-18T07:10:21Z")

</div>

That isn’t the problem at all.

See, the clip activates on rollOver of the red bar. Now, the problem with this is that the blue box moves to your mouse cursor.

You can’t rollOut of your red bar since the blue box is overlapping it.

I will try and fix it.

---

<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: [December 18, 2002, 7:33am UTC](https://forum.kirupa.com/t/should-be-simple-but-it-is-not/9762/5 "2002-12-18T07:33:11Z")

</div>

Ok, I think I came up with something that will work.

Give your red bar the instance name “redBar” (no quotes).

Remove all actionscript from the actions panel for that red bar.

Now open the actions panel for the blue box.

Apply these actions and these actions only to the blue box.

```auto
onClipEvent (enterFrame) {
	getlimits = _root.redBar.getBounds(_root);
	if (_root._xmouse>=getlimits.xMin && _root._xmouse<=getlimits.xMax && _root._ymouse>=getlimits.yMin && _root._ymouse<=getlimits.yMax) {
		this._x = _root._xmouse;
		this._y = 200;
	}
}

```

Give it a whirl… let me know how it goes 🙂

---

<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: [December 19, 2002, 12:16am UTC](https://forum.kirupa.com/t/should-be-simple-but-it-is-not/9762/6 "2002-12-19T00:16:40Z")

</div>

OMG you did it beta. I have been working on this for like a week and a half, but noooo! And you guys come along and get it worked out in one day. This really pisses me off, but ironically makes me happy at the same time. Thanks a bunch fellas.

---

<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: [December 19, 2002, 2:36am UTC](https://forum.kirupa.com/t/should-be-simple-but-it-is-not/9762/7 "2002-12-19T02:36:49Z")

</div>

No problem. You will get more and more used to AS the more you use it.

Practice makes perfect 🙂
