# Mouse follow

**URL:** https://forum.kirupa.com/t/mouse-follow/29527
**Category:** Uncategorized
**Created:** [August 27, 2003, 9:10pm UTC](https://forum.kirupa.com/t/mouse-follow/29527 "2003-08-27T21:10:07Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Kipper](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@Kipper](https://forum.kirupa.com/u/Kipper)
#### Post date: [August 27, 2003, 9:10pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/1 "2003-08-27T21:10:07Z")

</div>

hey all,  
i have worked out how to make the ball follow the mouse arrow but how do you make the two lines move together as in the flash file in the tutorial section?

```
                                     Kip
```

---

<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 27, 2003, 9:35pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/2 "2003-08-27T21:35:45Z")

</div>

which tut are you refurring 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: [August 27, 2003, 10:08pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/3 "2003-08-27T22:08:50Z")

</div>

you mean like a crosshair ?  
ok open flash; make two lines, one horizontal, one vertical and make them twice as large or high as the movie - call them two different movies; linehorizontal and linevertical or whatever…

for each movie (or you could code it in one another movie) write these action

vertical bar:

```auto

onClipEvent(enterFrame){
this._x = _root._xmouse
}

```

and the horizontal bar

```auto

onClipEvent(enterFrame){
this._y = _root._ymouse
}

```

you could also make the crosshair, turn it into a movie clip and set its registration point to its center, and set a startDrag command. But the one on top is better (to learn - i mean)

---

<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 27, 2003, 10:53pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/4 "2003-08-27T22:53:58Z")

</div>

hmmm when i do what uve just mentioned i get the lines moving but not staying together to make perfect cross

---

<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 27, 2003, 11:14pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/5 "2003-08-27T23:14:14Z")

</div>

😛

```auto

this.onEnterFrame = function () {
_root.createEmptyMovieClip("horz", 0);
_root.createEmptyMovieClip("vert", 1);
//horizontal line
horz.lineStyle(0, 0x000000, 100);
horz.moveTo(0, _root._ymouse);
horz.lineTo((_root._xmouse+400), _root._ymouse);
//vertical line
vert.lineStyle(0, 0x000000, 100);
vert.moveTo(_root._xmouse, 0);
vert.lineTo(_root._xmouse, (_root._ymouse+400));

};

```

I love this API crap!!

[edit] by the way, make your stage 400x400 or change the two 400s above to whatever…[/edit]

---

<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 27, 2003, 11:24pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/6 "2003-08-27T23:24:24Z")

</div>

humm not moving at all now lol ive prob put code in wrong i only learning sorry can u tell me what i put it atons for horiz and vert line ? sorry to causing hassle lol

---

<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 27, 2003, 11:30pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/7 "2003-08-27T23:30:15Z")

</div>

Take all that actionScript and put in the first frame of the movie - make sure that it’s on a layer that exists throughout the movie. (make a new layer if you have 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: [August 27, 2003, 11:39pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/8 "2003-08-27T23:39:50Z")

</div>

what I did works absolutely fine for me: check the fla

the API thing is great too but a bit tough for a beginner =)  
[http://mlkdesign.online.fr/misc/kirupa/crosshair.fla](http://mlkdesign.online.fr/misc/kirupa/crosshair.fla)  
\<embed src=“[http://mlkdesign.free.fr/misc/kirupa/crosshair.swf](http://mlkdesign.free.fr/misc/kirupa/crosshair.swf)” height=200 width=300" type=application/x-shockwave-flash\>\</embed\>

---

<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 27, 2003, 11:43pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/9 "2003-08-27T23:43:17Z")

</div>

ahh haaa cheers beers! i only been at this for 3 weeks but heres a file ive been working on let me know what you think  
Also can i make the lines already visible on the fla before the mouse is placed over 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: [August 27, 2003, 11:45pm UTC](https://forum.kirupa.com/t/mouse-follow/29527/10 "2003-08-27T23:45:49Z")

</div>

True, but I was excited because I could just made it work - I had to share 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: [August 28, 2003, 12:17am UTC](https://forum.kirupa.com/t/mouse-follow/29527/11 "2003-08-28T00:17:18Z")

</div>

can i make the crosshair visable on the fla before the mouse is held over 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: [August 28, 2003, 12:26am UTC](https://forum.kirupa.com/t/mouse-follow/29527/12 "2003-08-28T00:26:48Z")

</div>

Using MLK’s design (…teehee) add this before the onClipEvent(enterFrame) on both of the crosshair movieClips:

```auto

onClipEvent(load){
_x = 100;
_y = 100;
}

```

Adjust accordingly. For mine, it would take a little bit.
