# Difference between writing doFunction; and doFunction();

**URL:** <https://forum.kirupa.com/t/difference-between-writing-dofunction-and-dofunction/246349>\
**Category:** flash\
**Created:** [December 10, 2007, 11:54am UTC](https://forum.kirupa.com/t/difference-between-writing-dofunction-and-dofunction/246349 "2007-12-10T11:54:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpixel](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jpixel](https://forum.kirupa.com/u/jpixel)\
**Post date:** [December 10, 2007, 11:54am UTC](https://forum.kirupa.com/t/difference-between-writing-dofunction-and-dofunction/246349/1 "2007-12-10T11:54:22Z")

</div>

I was writing a simple app, basically a listener that calculated the distance of the mouse from a movieclip…However the calculation function only started working properly once I wrote the doFunction(); part as doFunction; -without the brackets.

before that, it would calculate it once and not trace the distance again,

after removing brackets, it traced value whenever the mouse moved (how I wanted it)

I’m glad it’s working, but would like to know the reason for this difference…Here is the code:

distanceListen=new Object();

Mouse.addListener(distanceListen);

distanceListen.onMouseMove = distanceCalc;

function distanceCalc(){

//mouse pos from square  
xdist = Math.round(\_xmouse - squaremc.\_x-15);  
ydist = Math.round(\_ymouse - squaremc.\_y-15);

//calc dist using basic trig  
distancefromthis = Math.round(Math.sqrt((xdist_xdist) + (ydist_ydist)));

//and trace distance value  
trace(distancefromthis);  
statustxt.text=distancefromthis;

}
