# Functions

**URL:** <https://forum.kirupa.com/t/functions/64264>\
**Category:** Uncategorized\
**Created:** [September 14, 2004, 5:25pm UTC](https://forum.kirupa.com/t/functions/64264 "2004-09-14T17:25:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jive](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@jive](https://forum.kirupa.com/u/jive)\
**Post date:** [September 14, 2004, 5:25pm UTC](https://forum.kirupa.com/t/functions/64264/1 "2004-09-14T17:25:35Z")

</div>

I’m reading Colin Moocks Actionscript for flash MX book and upon reading functions he instructs to create a symbol named ballSymbol, than put an instance on the stage (frame 1 maintimeline) and call it ball. Than on frame 1 on the main timeline put the following actionscript:

```auto

_global.mainTimeline = this;
 
function moveBall() {
mainTimeline.ball._x += 10;
mainTimeline.ball._y += 10;
};
moveBall();

```

The ball is supposed to move diagonally. But my problem is when I test the movie, nothing happens. No movement, nothing…

What am I missing?

---

<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:** [September 14, 2004, 5:43pm UTC](https://forum.kirupa.com/t/functions/64264/2 "2004-09-14T17:43:27Z")

</div>

so mainTimeline is a movieclip that contains an instance of ball?

Make sure all movieclips have an instance name and try again.

:hr:

---

<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:** [September 14, 2004, 5:48pm UTC](https://forum.kirupa.com/t/functions/64264/3 "2004-09-14T17:48:59Z")

</div>

You don’t see anything because that code (or at least the part you posted) is only executed once. What you see is the ball after it has moved 10px to the right and 10px to the bottom. To keep it executing, use for example an onEnterFrame handler:

```auto
this.onEnterFrame = function(){
moveBall();
}

```

That’ll keep it moving.

---

<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:** [September 14, 2004, 11:26pm UTC](https://forum.kirupa.com/t/functions/64264/4 "2004-09-14T23:26:46Z")

</div>

it is important to know that both the function to move the ball and the EnterFrame command should be placed **inside** the ball movie clip.
