Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse XY position capture... 1

Status
Not open for further replies.

brutteforcce

Technical User
Jun 23, 2006
105
RO
I need a script that calculates all the time the XY position of the mouse on a page and can be moved over the page...

---------
| x = 0 |
| y = 0 |
---------

It should look something like this when the pointer is at the begining of the page and it should be grabbed and put in any place on the page ( the positions will be the same, just shown in another place )...

You can see what I want here :
The same thing but made in Flash , movable and if it's possible to show the position in franctional numers ( 0.2, 30.4)...

Please help me!
 
_xmouse and _ymouse keep track of the position of the mouse.

example...
Code:
trace("Mouse X: " + _xmouse);
trace("Mouse Y: " + _ymouse);
is that what you were wanting?

as for displaying its position as a floating point number, that wont happen, unless you want a bunch of zeros after the decimal.

though, if you wanted to try, do it like this...

Code:
trace("Mouse X: " + parseFloat(_xmouse));
trace("Mouse Y: " + parseFloat(_ymouse));
but again, you'll probably just get zeros after the decimal.

--
Matt Milburn, Wave Motion Studios
matt@wavemotionstudios.com
 
I didn't wanted it in the output window, but it's fine there too...
The problem is that it doesn't work, it shows the position the first time when I start it, but it doesn't keep tracking the position all the time, if I move the mouse over the swf nothing happens...
I want to do this thing so I can see some positions from a picture and to rebuild the thing but in pieces... If the picture has a square I should see his position and size... I can calculate the size by decreasing the size from a corner and the size of another one...
If you have better ideas to do this things please tell me, if not tell me how can I apply my idea...
Does it make sense?
Please help me!
 
You can use a movie clip with nested dynamic textfields, and use an onEnterFrame() function on the movie clip, so that it constantly monitors the mouse's coordinates...

myClip.onEnterFrame = function(){
Xcoord.text = _xmouse;
Ycoord.text = _ymouse;
};

Furthermore, you could set this mc to be dragged with startDrag()...


Regards. Web Hosting - Web Design
03/13/05 -> OLDNEWBIE VS FLASHKIT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top