# MC incorrectly referencing \_parent MC

**URL:** <https://forum.kirupa.com/t/mc-incorrectly-referencing--parent-mc/252314>\
**Category:** programming\
**Created:** [February 18, 2008, 11:17pm UTC](https://forum.kirupa.com/t/mc-incorrectly-referencing--parent-mc/252314 "2008-02-18T23:17:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ken\_Rogers](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@Ken\_Rogers](https://forum.kirupa.com/u/Ken_Rogers)\
**Post date:** [February 18, 2008, 11:17pm UTC](https://forum.kirupa.com/t/mc-incorrectly-referencing--parent-mc/252314/1 "2008-02-18T23:17:50Z")

</div>

On the main timeline, Using attachMovie I am creating several instances of a movieclip called [COLOR=Red]aircraft. [COLOR=Black]These [COLOR=Red]aircraft[/COLOR] movieclips all have a movieclip inside them called [COLOR=Red]pps[/COLOR].

When the [COLOR=Red]pps[/COLOR] movieclip tries to reference it’s parent movieclip [COLOR=Red]aircraft[/COLOR], [COLOR=Red]pps[/COLOR] references all [COLOR=Red]aircraft[/COLOR] movieclips. It is only supposed to reference the single movieclip in which it resides.

[COLOR=Black]//this code is on the main timeline, and it creates several new instances of [COLOR=Red]aircraft[/COLOR]. Flash correctly places these on their own levels (I have trace tested this).[/COLOR]  
[COLOR=Green]var num\_movie\_clips = 0;

function createAircraft() {  
\_root.attachMovie(“aircraft”, “aircraft”+num\_movie\_clips, num\_movie\_clips);  
num\_movie\_clips++;  
}

[COLOR=Black]//inside the [COLOR=Red]aircraft[/COLOR] movieclip lives [COLOR=Red]pps[/COLOR], which tries to reference it’s parent with this code on it’s timeline.[/COLOR]  
\_parent.headingAssigned = degrees;

[COLOR=Black] **What happens:** The headingAssigned variable of the parent movieclip [COLOR=Red]aircraft [COLOR=Black]accepts its new value. However, the headingAssigned variable of ALL OTHER [COLOR=Red]aircraft[/COLOR] movieclips gets the value NaN.[/COLOR][/COLOR][/COLOR]

Ken  
[/COLOR][/COLOR][/COLOR]
