header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Genieee
Points:0
Posts:0

10/17/2010 10:10:27 PM

Title: How can I calculate mouse move speed?


Hi,

Can anybody tell us, how can I calculate mouse speed when I move the mouse.
http://www.dressupone.com/dressupgames/462/kissing-championship.html

Like this game... I want to do some animation as per the user mouse speed.

Thanks in advance,
Genieee



1
Ronald
Points: 430
Posts:0
10/17/2010 10:37:33 PM



you can create a timer which will calculate the sped periodically say 100 milliseconds.

now on every timer event you need to store the initial x,y positions of the mouse and compare with the old saved x,y positions. Like this



newX=mouseX
newy=mouseY

//by substracting the new distance from old one you will get how many pixels were traveled in 100 milliseconds. And that's the speed 
speed= (newX+newY)-(oldX-oldY);

oldX=mouseX
oldY=mouseY



Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 1+5 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions