# onMouseMove with getTimer()?

**URL:** https://forum.kirupa.com/t/onmousemove-with-gettimer/7247
**Category:** Uncategorized
**Created:** [October 26, 2002, 6:31pm UTC](https://forum.kirupa.com/t/onmousemove-with-gettimer/7247 "2002-10-26T18:31:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kwanie](https://avatars.discourse-cdn.com/v4/letter/k/c2a13f/32.png) [@kwanie](https://forum.kirupa.com/u/kwanie)
#### Post date: [October 26, 2002, 6:31pm UTC](https://forum.kirupa.com/t/onmousemove-with-gettimer/7247/1 "2002-10-26T18:31:05Z")

</div>

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

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](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!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 28, 2002, 4:46am UTC](https://forum.kirupa.com/t/onmousemove-with-gettimer/7247/2 "2002-10-28T04:46:57Z")

</div>

what does this mean?

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 28, 2002, 5:40am UTC](https://forum.kirupa.com/t/onmousemove-with-gettimer/7247/3 "2002-10-28T05:40:55Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 29, 2002, 8:19am UTC](https://forum.kirupa.com/t/onmousemove-with-gettimer/7247/4 "2002-10-29T08:19:16Z")

</div>

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. 🙂

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

```php

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!)
