<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  styleName="plain" layout="horizontal" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10" xmlns:local="*" viewSourceURL="srcview/index.html"
  backgroundColor="#ffffff" backgroundGradientColors="#ffffff,#ffffff">

  <mx:Script>
    import org.as3commons.reflect.MetaData;
    import org.as3commons.reflect.ClassUtils;
    import org.as3commons.reflect.Type;
  
    import mx.collections.ArrayCollection;  
  
    import ru.etcs.utils.getDefinitionNames;
  </mx:Script>

  <mx:applicationComplete>
  <![CDATA[
    // link in the classes
    if (0)
    {
      var someClasses:SomeClasses = new SomeClasses();
    }

    var a:Array = getDefinitionNames(systemManager.loaderInfo);
    
    allClasses.dataProvider = a;
    
    ifooClasses.dataProvider = new ArrayCollection();
    metafooClasses.dataProvider = new ArrayCollection();
    
    for each (var cn:String in a)
    {
      var t:Type = Type.forName(cn);
      for each (var md:MetaData in t.metaData)
      {
        if (md.name == "MetaFoo")
        {
          metafooClasses.dataProvider.addItem(cn);
          break;
        }
      }
      
      if (ClassUtils.getImplementedInterfaceNames(t.clazz).indexOf("IFoo") >= 0)
      {
        ifooClasses.dataProvider.addItem(cn);
      }
    }
    ]]>
  </mx:applicationComplete>

  <mx:Panel title="All Classes" width="100%" height="100%">
    <mx:List id="allClasses" width="100%" height="100%"/>
  </mx:Panel>
  
  <mx:Panel title="Classes that implement IFoo" width="100%" height="100%">
    <mx:List id="ifooClasses" width="100%" height="100%"/>
  </mx:Panel>
  
  <mx:Panel title="Classes that have MetaFoo metadata" width="100%" height="100%">
    <mx:List id="metafooClasses" width="100%" height="100%"/>
  </mx:Panel>

</mx:Application>