# Function run order

**URL:** https://forum.kirupa.com/t/function-run-order/283416
**Category:** flash
**Created:** [March 5, 2009, 8:21pm UTC](https://forum.kirupa.com/t/function-run-order/283416 "2009-03-05T20:21:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![briand5](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@briand5](https://forum.kirupa.com/u/briand5)
#### Post date: [March 5, 2009, 8:21pm UTC](https://forum.kirupa.com/t/function-run-order/283416/1 "2009-03-05T20:21:25Z")

</div>

Hi, I am running into a problem with functions. I three functions and they must run in order to work properly. Right now the run order is: function 1, function 3, function 2 even though in my actionscripting them in the correct order.

Here is my code:

Function1:  
Grill\_over.onRollOver = function() {  
if ((overHamburgers == 0) && (overGrill == 0)) {  
Grill\_mc.gotoAndPlay(“startOpen”);  
overGrill = 1  
}}

Function2:  
H1.onRollOver = function() {  
overHamburgers = 1;  
trace(overHamburgers);  
captionFN(true, “Burgers.”, this);

this.onRollOut = function() {  
overHamburgers = 0;  
trace(overHamburgers);  
captionFN(false);  
};};

Function3:  
Grill\_over.onRollOut = function() {  
if ((overHamburgers == 0) && (overGrill == 1)) {  
Grill\_mc.gotoAndPlay(“startClose”);  
overGrill = 0  
}}

Basically what I need is to make sure the second function if rolled over runs and sets the variable “overHamburgers” to 1 before function 3 runs and tries to roll out. If anyone could help me out I would appreciate it.

Thanks,  
Brian
