PDA

View Full Version : N00B Question: Mouse Movement



JornB
September 7th, 2008, 01:12 PM
I'm a n00b when it comes to scripting and I have an idea on an implementation:

- An user moves the mouse pointer over a specific area, then a sound is played.

- The higher the frequence of movement over the area another sound is played.

- To add to this I also want a background pic to change.

Hope anyone can help me out, and thanks for your time!

SparK_BR
September 7th, 2008, 03:58 PM
you could add a timer to check the mouse position, get the diference betwen before and after, the higher the difference, higher the frequence



var oldPosX = -1;
var oldPosY = -1;

var mouseFrequence = 0;

setInterval("checkMouseFrequence", 100, true);

function checkMouseFrequence(){
var frequence = 0;
var freqX;
var freqY;
if(oldPosY >= 0 and oldPosX >= 0){
freqX = _root._xmouse - oldPosX;
freqY = _root._ymouse - oldPosY;
frequency = Math.sqrt((freqX*freqX)+(freqY*freqY));
}
mouseFrequence = frequence;
}


then mouseFrequence will be your movementOmeter

>about the sound effects i can't help... it's beyound my aknowledge (never worked with sounds in flash)