1 Reply Latest reply on Nov 12, 2010 12:00 PM by Flex harUI

    Are there any workarounds to get compile-time type checking for method overloads?

    JoshBeall Level 1

      Hi All,

       

      I understand that AS3 does not have method overloading.  I'd like to do something liek this:

       

      public static function getElements(parent:GroupBase):Vector.<IVisualElement>{
           return _getElements(parent);
      }
      
      public static function getElements(parent:SkinnableContainer):Vector.<IVisualElement>{
           return _getElements(parent);
      }
      

       

      But I can't.  So, is there any way I can get compile-time type checking?  I understand that I could accept any object, and then check the object type at run-time and throw an exception if it's not one of the types that my methods accepts.  But I'm wondering if there's any way to do this at compile time.

       

      Another way to accomplish what I want would be to have the compiler to check to see that the passed type has a ".getElementAt(index:int)" method.  Maybe there's a way to do that?

       

      Thanks!

       

        -Josh