# Order of execution not respected? o.0

**URL:** <https://forum.kirupa.com/t/order-of-execution-not-respected-o-0/318761>\
**Category:** Uncategorized\
**Created:** [January 29, 2011, 6:05pm UTC](https://forum.kirupa.com/t/order-of-execution-not-respected-o-0/318761 "2011-01-29T18:05:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![OMG](https://avatars.discourse-cdn.com/v4/letter/o/9dc877/32.png) [@OMG](https://forum.kirupa.com/u/OMG)\
**Post date:** [January 29, 2011, 6:05pm UTC](https://forum.kirupa.com/t/order-of-execution-not-respected-o-0/318761/1 "2011-01-29T18:05:03Z")

</div>

I don’t know where I went wrong with this code, but here it is:  
main swf: stage empty, a function creates 1 enemy and 2 arrows from library and place them so that the two arrow clips touch the enemy clip.  
inside Arrow clip: first frame stop();hit()  
inside Enemy clip: stop()

inside Arrow class in an external .as file:

```php
public function hit() {
			if (this.hitTestObject(arr)) {
				trace("trace1",this.name);
				arr.gotoAndPlay(2);
				trace("this should follow trace1",this.name);
				arr.doThat();
			}
		}

```

inside Enemy class:

```php
public function doThat() {
			this.gotoAndPlay(3);
		}

```

main swf output:  
trace1  
trace1  
this should follow trace1  
this should follow trace1

output if I remove the “gotoAndPlay” command between the traces in Arrow:  
trace1  
this should follow trace1  
trace1  
this should follow trace1

why did the execution order change? or is it some logical flaw I didn’t understand?

thanks
