onMouseMove with getTimer()?

hi! i’m pretty new at actionscript. struggling actually… so thanks for all your help in advance :slight_smile:

I need help with a time function with an onMouseMove function.

I want to be able to do a couple of things:

The movie clip must be globally be able to calculate,
if the distance from _x position of the mouse to another _x position of the mouse is say (for example) less than 20 pixels, and the time to achieve less than 20 pixels is less than 2 second,
then go to and play an external movie clip (which must be absolutely positioned at a specific cooridinates.

I am planning to have like 3 similar movie clips detecting different distances calculations and time, so that each will go and play different movie clips for different specifications.

I dont know where getTimer() gets into this but i have a very deep feeling it does :cyclops:

I was browsing:
http://www.kirupaforum.com/showthread.php?threadid=6355&perpage=15&highlight=mouse%20move&pagenumber=2
It is a similar concept i think but mine requires calcuation of pixels and the positioning parts.

I’m pretty distressed! I hope I’m pretty thanks! Thanks for your help!

what does this mean?

, and the time to achieve less than 20 pixels is less than 2 second,

it means …
if the time taken for the mouse to move from…
_x1 to another _x2
is less than 2 seconds.

_x1 to _x2 = 20 pixels.

ie:

i am moving my mouse and the mouse accumulates 20 pixels within 2 seconds. then go to play an external movie clip.

Interesting. I hadn’t thought that there was an aplication for that, but that is the beuty of Flash after all. With so many people, there are always more ideas poping up. :slight_smile:

well, getTimer(); gets the number of miliseconds since the start of the movie. We can set variables to equal it at any time.

I’m just taking guesses right now… but here are some things to look at


onClipEvent (load){
    //I just threw this in to show dynamic naming potencial
    clipName="theNameOfMyMovieClip";
    //these allow control of the parameters more easily
    timeRequired=2;
    distanceRequired=20;
    trip=false;
    function initiate(){
        t1=getTimer();
        mx1=_root._xmouse;
        my1=_root._ymouse;
        trip=true;
    }
    funtion test(){
        t=t2-t1;
        lQ= (mx1 mx2 my1 my2);
        if(t<timeRequired&&lQ>distanceRequired){
            _root[clipName].play();
        }
    }
}
onClipEvent (enterFrame) {
    if(trip){
        t2=getTimer();
        mx2=_root._xmouse;
        my2=_root._ymouse;
        test();
    }
}

NOT DONE**
I’m still working on the final mathmatics for this code, so this is not done. Just an outline for me to work off of. I have to get the math from my home comp. (stupid brain!)