# Help! with mouse pos and dynamic text

**URL:** https://forum.kirupa.com/t/help-with-mouse-pos-and-dynamic-text/829
**Category:** Uncategorized
**Created:** [July 17, 2002, 3:33am UTC](https://forum.kirupa.com/t/help-with-mouse-pos-and-dynamic-text/829 "2002-07-17T03:33:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![3dron](https://avatars.discourse-cdn.com/v4/letter/3/2acd7d/32.png) [@3dron](https://forum.kirupa.com/u/3dron)
#### Post date: [July 17, 2002, 3:33am UTC](https://forum.kirupa.com/t/help-with-mouse-pos-and-dynamic-text/829/1 "2002-07-17T03:33:47Z")

</div>

I put this script on the movieclip of background which is present the entire flash project.

onClipEvent(mouseMove){  
x\_pos = \_root.\_xmouse;  
y\_pos = \_root.\_ymouse;  
}

Then I create a ‘dynamic text’ object. With variable set to ‘x\_pos’ (why is it that I have to make the title of this text object ‘x\_pos’ as well?)

This is what the text spits out at runtime:

\_level0.x\_pos

What is the deal?

Thanks for any help  
RR

---

<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: [July 17, 2002, 7:25am UTC](https://forum.kirupa.com/t/help-with-mouse-pos-and-dynamic-text/829/2 "2002-07-17T07:25:17Z")

</div>

you don’t have to make the name of the text box ‘x\_pos’, just the variable. that might be causing your problem.

---

<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: [July 17, 2002, 7:44am UTC](https://forum.kirupa.com/t/help-with-mouse-pos-and-dynamic-text/829/3 "2002-07-17T07:44:41Z")

</div>

put this in frame 1 instead:

```auto

_root.createTextField("mouseTracker",1000,0,0,0,0);
mouseTracker.f = new TextFormat("Verdana",10);
mouseTracker.autoSize = "left";
mouseTracker.selectable = 0;
mouseTracker.onMouseMove = function(){
	this.text = "x:"+_root._xmouse+"
y:"+_root._ymouse;
	this.setTextFormat(this.f);
}
Mouse.addListener(mouseTracker);

```

then you don’t need a movieClip.

---

<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: [July 17, 2002, 7:48am UTC](https://forum.kirupa.com/t/help-with-mouse-pos-and-dynamic-text/829/4 "2002-07-17T07:48:06Z")

</div>

the problem you were having was that when you put your actions on a movie, you were setting those variables in that movie’s timeline.

a slight adjustment:

```auto

onClipEvent(mouseMove){
   _root.x_pos = _root.xmouse;
   _root.y_pos = _root.ymouse;
}

```

putting that on a movie and leaving everything else will solve your problem, since it’s putting the variables on \_root which is where your text box is looking for them.

or use the code i put above and forget about miscellaneous movies. : )

---

<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: [July 17, 2002, 7:34am UTC](https://forum.kirupa.com/t/help-with-mouse-pos-and-dynamic-text/829/5 "2002-07-17T07:34:03Z")

</div>

The macromedia tutorial I was reading says to place

ClipEvent(mouseMove){  
x\_pos = \_root.\_xmouse;  
y\_pos = \_root.\_ymouse;  
}

On any frame of the top level so the mouse pos is always updating. But when I go to publish, I get an error say clip actions can only be placed on movie clips.

When I place the above ascipt on a movieclip, I get no mouse coords, even when I roll over the box.

If I put just the

x\_pos = \_root.\_xmouse;  
y\_pos = \_root.\_ymouse;

Then I get the initial mouse coords when the file started, but it doesn’t update. Help!!!

RR
