# onMotionFinished and calling other functions

**URL:** <https://forum.kirupa.com/t/onmotionfinished-and-calling-other-functions/199808>\
**Category:** flash\
**Created:** [September 6, 2006, 9:13am UTC](https://forum.kirupa.com/t/onmotionfinished-and-calling-other-functions/199808 "2006-09-06T09:13:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grudge](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@Grudge](https://forum.kirupa.com/u/Grudge)\
**Post date:** [September 6, 2006, 9:13am UTC](https://forum.kirupa.com/t/onmotionfinished-and-calling-other-functions/199808/1 "2006-09-06T09:13:05Z")

</div>

I have this function that builds menus, and I’m using a tweening class function to move the menu items around. The thing is that when calling the tween function I need the submenu building function to wait until the tween is finished otherwise things start freaking out.

It’s organized like this (pseudo code):

```
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000] **function** [/COLOR] tweenItem[COLOR=#000000]([/COLOR][COLOR=#0000FF]movieclip[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]

```

[COLOR=#000000][[/COLOR]tweens the item[COLOR=#000000]][/COLOR];  
[COLOR=#0000FF]movieclip[/COLOR].[COLOR=#000080]onMotionFinished[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
buildSubmenu;  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR];  
[COLOR=#000000] **function** [/COLOR] buildMenuCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
tweenItemCOLOR=#000000[/COLOR];  
[COLOR=#000000] **function** [/COLOR] buildSubmenuCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
buildMenuCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
tweenItemCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR];  
[/LEFT]  
[/FONT]

The problem is that I need the first tweening to finish before I can build the submenu. I’ve tried using the onMotionFinished, but it doesn’t seem to want to call a function nestled into another function (in this case buildMenu()).

Does anyone have any ideas about how to do this?
