Enterframe being executed only once


stop();
var numOfItems=1;
var radiusX =30;
var radiusY = 75;
var centerX = Stage.width / 2;
var centerY = Stage.height / 2;
var speed = 0.05;

for(var i=0;i<numOfItems;i++)
{
    var logo=this.attachMovie("logo_mc","logo_"+i,i+1);
    logo.angle = i*((Math.PI*2)/numOfItems);
    logo.onEnterFrame=move_function();
}


function move_function()
{
    this._x = Math.cos(this.angle)*radiusX+CenterX;
    this._y = Math.sin(this.angle)*radiusY+CenterY;
    this.angle+= this._parent.speed;
}

I have the following code in one of the frames in my game…but for some reason the move_function() is being called only once…why is this happening, and how do i fix it?

because it’s happening only when it enters frame.

put it inside a:

onEnterFrame = function{

}

And it’ll be called all the time.

you don’t need the brackets

ie

 logo.onEnterFrame=move_function;

not

 logo.onEnterFrame=move_function();

Thanks neilmmm, it worked perfectly…but i dont understand how it worked? what is the difference with () and removing them? oh…and if i cannot use those braces, how will i pass parameters to the function?

logo.onEnterFrame=move_function();

executes the function and assigns the return value to onEnterFrame

logo.onEnterFrame=move_function;

Assigns the function itself to onEnterFrame.

You can only pass parameters at the time the function is executed.