title: Why are a DisplayObject's child's .name property and the results of getChildByName() sometimes different?
body: <p>Can anyone explain the difference between the "name" property of a display object and the value found by <em>getChildByName("XXX")</em> function?  They're the same 90% of the time, until they aren't, and things fall apart.</p>
  
  <p>For example, in the code below, I find an object by instance name only by directly examining the child's name property; <em>getChildByName()</em> fails.   </p>
  
  <pre><code>var gfx:MovieClip = new a_Character(); //(a library object exported for Actionscript)
  
  var do1:DisplayObject = null;
  var do2:DisplayObject = null;
  
  for( var i:int = 0 ; i &lt; gfx.amSword.numChildren ; i++ )
  {
      var child:DisplayObject = gfx.amSword.getChildAt(i);
      if( child.name == "amWeaponExchange" )  //An instance name set in the IDE
      {
          do2 = child;
      }
  }
  
  trace("do2:", do2 );
  
  var do1:DisplayObject = gfx.amSword.getChildByName("amWeaponExchange");
  </code></pre>
  
  <p>Generates the following output:</p>
  
  <pre><code>do2: [object MovieClip]
  ReferenceError: Error #1069: Property amWeaponExchange not found on builtin.as$0.MethodClosure and there is no default value.
  </code></pre>
  
  <p>Any ideas what Flash is thinking?</p>