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!

Sending mouse coordinates to PHP????

Status
Not open for further replies.

noaaprogrammer

Programmer
May 4, 2001
36
US
I am attempting to create a Flash game that interacts with a MySQL database using PHP. I created a 600x600 pixel .jpeg in Fireworks, and would like to import it into Flash. I want the user to click on a spot of the image, and I want Flash to send the coordinates of the mouse click to a PHP file. Does anyone know how to do this?

I imported my jpeg as a button so that I could use the "onMouseEvent" function. I added getURL function to it for when the mouse is pressed, and put "handle.php?_xmouse". When I run the movie, I can click on the image, and it will call the PHP file. But it isn't passing the x mouse coordinate. It just passes the literal string "_xmouse".
 
But how are you reading the mouse's coordinates when the mouse is pressed?
 
Okay. I got Flash to send the X-Y coordinates to my PHP file. I changed the jpeg from a button to a movie clip. That allowed me to add this action script to it:

onClipEvent (mouseDown) {
myX = _root._xmouse;
myY = _root._ymouse;
getURL("testing.php","_self","get");
}

The only problem is that when the cursor is placed over it, it doesn't change to the hand pointer that you get when placing your cursor over something that is clickable.
 
On the first frame of your movie...

this.onEnterFrame = function(){
my_mouseX = Math.round(_xmouse);
//trace (my_mouseX);
};

Then pass my_mouseX on your getURL...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top