type = 'application/x-shockwave-flash'
data = 'http://sitepointstatic.com/flash/mousepos.swf'
width = '400'
height = '400'
bgcolor = 'black'

Download the sample files here.

1. Create a movieclip from any object.

2. Give the movieclip instance a name – I used "drag".

3. Create two text fields give them variable names xtxt and ytxt.

4. Go to the drag movieclip timeline.

5. Create 2 keyframes as shown below:


6.In the first key frame use the action:

startDrag ("/drag", true);  
/:xtxt = getProperty("/drag",_x);  
/:ytxt = getProperty("/drag",_y);

7. In the second key frame use the action:

gotoAndPlay (1); 

8. Bravo! You have made your own cool mouse position detector.

Georgina has more than fifteen years' experience writing and editing for web, print and voice. With a background in marketing and a passion for words, the time Georgina spent with companies like Sausage Software and sitepoint.com cemented her lasting interest in the media, persuasion, and communications culture.

No Reader comments

Special Offer
Free course!

Git into it! Bonus course Introduction to Git is yours when you take up a free 14 day SitePoint Premium trial.