# Enterframe being executed only once

**URL:** <https://forum.kirupa.com/t/enterframe-being-executed-only-once/259959>\
**Category:** Uncategorized\
**Created:** [May 10, 2008, 10:28pm UTC](https://forum.kirupa.com/t/enterframe-being-executed-only-once/259959 "2008-05-10T22:28:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluemagica](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@bluemagica](https://forum.kirupa.com/u/bluemagica)\
**Post date:** [May 10, 2008, 10:28pm UTC](https://forum.kirupa.com/t/enterframe-being-executed-only-once/259959/1 "2008-05-10T22:28:15Z")

</div>

```auto

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?

---

<div class="post-metadata">

**Author:** ![zuperxtreme](https://avatars.discourse-cdn.com/v4/letter/z/e9a140/32.png) [@zuperxtreme](https://forum.kirupa.com/u/zuperxtreme)\
**Post date:** [May 10, 2008, 10:45pm UTC](https://forum.kirupa.com/t/enterframe-being-executed-only-once/259959/2 "2008-05-10T22:45:08Z")

</div>

because it’s happening only when it enters frame.

put it inside a:

onEnterFrame = function{

}

And it’ll be called all the time.

---

<div class="post-metadata">

**Author:** ![neilmmm](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@neilmmm](https://forum.kirupa.com/u/neilmmm)\
**Post date:** [May 11, 2008, 2:09am UTC](https://forum.kirupa.com/t/enterframe-being-executed-only-once/259959/3 "2008-05-11T02:09:28Z")

</div>

you don’t need the brackets

ie

```auto
 logo.onEnterFrame=move_function;

```

not

```auto
 logo.onEnterFrame=move_function();

```

---

<div class="post-metadata">

**Author:** ![bluemagica](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@bluemagica](https://forum.kirupa.com/u/bluemagica)\
**Post date:** [May 11, 2008, 6:23am UTC](https://forum.kirupa.com/t/enterframe-being-executed-only-once/259959/4 "2008-05-11T06:23:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rrh](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rrh](https://forum.kirupa.com/u/rrh)\
**Post date:** [May 12, 2008, 3:27pm UTC](https://forum.kirupa.com/t/enterframe-being-executed-only-once/259959/5 "2008-05-12T15:27:14Z")

</div>

```auto
logo.onEnterFrame=move_function();

```

executes the function and assigns the return value to onEnterFrame

```auto
logo.onEnterFrame=move_function;

```

Assigns the function itself to onEnterFrame.

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