title: How do functions with multiple parameters of the same name work?
body: <p>I've been looking through the code for a Flash game (<a href="http://www.shockwave.com/gamelanding/plantsvszombies.jsp" rel="nofollow noreferrer">link</a>).  However, I'm having trouble understanding how some of these functions work, especially because some of them have function definitions that I would think to fail to get past the compiler.</p>
  
  <p>The following is some code from TodCommon.as that appears to conflict with itself (or at the very least uses bad naming conventions).</p>
  
  <pre class="lang-js prettyprint-override"><code>private static var gFlashingColor:Color = new Color();
  
  final public static function ClampFloat(ClampInt:Number, ClampInt:Number, ClampInt:Number) : Number
  {
      if(ClampInt &lt;= ClampInt)
      {
          return ClampInt;
      }
      if(ClampInt &gt;= ClampInt)
      {
          return ClampInt;
      }
      return ClampInt;
  }
  
  final public static function ClampInt(gFlashingColor:int, gFlashingColor:int, gFlashingColor:int) : int
  {
      if(gFlashingColor &lt;= gFlashingColor)
      {
          return gFlashingColor;
      }
      if(gFlashingColor &gt;= gFlashingColor)
      {
          return gFlashingColor;
      }
      return gFlashingColor;
  }
  
  
  </code></pre>
  
  <p>Also in the code is the weirdest syntax for a for-each loop that I've ever seen (this example also features a package name as a parameter name)</p>
  
  <pre class="lang-js prettyprint-override"><code>public function CountPlantByType(com.popcap.flash.framework.resources.fonts:int) : int
  {
      var _loc_3:CPlant = null;
      var _loc_2:int = 0;
      var _loc_4:int = 0;
      var _loc_5:* = this.mPlants;
      while(&lt;to complete&gt;)
      {
          _loc_3 = __nextvalue;
          if(_loc_3.mSeedType != com.popcap.flash.framework.resources.fonts)
          {
              break;
          }
          _loc_2++;
      }
      return _loc_2;
  }
  </code></pre>
  
  <p>Those are just a few examples of things that I think look super weird and am having trouble understanding.  But these functions all work and are used extensively throughout the code.  Can someone explain how the ClampFloat and ClampInt functions work, or why it's legal to use a package name as a parameter? Thanks</p>