title: AS3 Loading a Class using getDefinition()
body: <p>I have hit a road block on this and would highly appreciate if someone can help me on this, please. What I am trying to do is to use shared runtime library by loading a swf ('index.swf') which has numerous library objects which are named in sequence such as:</p>
  
  <p>(orange1,orange2,orange3,orange4)
  (red1,red2,red3,red4)</p>
  
  <p>I am able to load the swf('index.swf') without any issues and even am able to load the right library asset, but I have to declare the full name as string such as getDefinition('orange1'). What I would like to do is to match first three letters of string and then run a for loop to load up all the classes that match the first three letters. I usually can do this by employing indexOf() method.</p>
  
  <p>here is my code:</p>
  
  <pre><code>public function loadContent():void
  {
  
  ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
  ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onloadHandler);
  ldr.load(req);
  
  }
  
  public function progressHandler(eProgress:ProgressEvent):void
  {
  var percent:Number = (eProgress.bytesLoaded / eProgress.bytesTotal);
  trace(percent);
  }
  
  public function onloadHandler(e:Event):void
  {
  // THIS IS WHERE I AM TRYING TO MATCH THE STRING
  var str:String = "red";
  str = (str.indexOf(str));
  var ref1:Class = e.currentTarget.applicationDomain.getDefinition(str) as Class
  trace(ref1);
  
  }
  </code></pre>
  
  <p>I would highly appreciate your help.</p>
  
  <p>Thanks.</p>