title: Create a different class from a string
body: <p>Hello I have this bit of code, and it what it must do is when there is some class (always extending the Box class) that must be spawned if there is already one of the same type it loads that one and if there is no one it creates a new one.</p>
  
  <pre><code>private var _l:Vector.&lt;Box&gt; = new Vector.&lt;Box&gt;();
  public function respawn(shapeId:int, className:String = "Box"):Class {
          var l:int = _l.length, i:int;
          var c:Class;
          var ct:Class = getDefinitionByName(className) as Class;
          for (i = 0; i &lt; l; i++) {
              c = _l[i];
              if (!c.active &amp;&amp; c.shapeId == shapeId) {
                  return c;
              }
          }
          c = new ct();
          _l[l] = c;
  
          return c;
      }
  </code></pre>
  
  <p>If I try this code it generates these errors:</p>
  
  <pre><code>Implicit coercion of a value of type com.shapes:Box to an unrelated type Class.
  Implicit coercion of a value of type Class to an unrelated type com.shapes:Box
  </code></pre>
  
  <p>How can I fix this so I can create different types of classes that all extend the Box class and get them into a <code>Vector.&lt;Box&gt;</code>?</p>