0 Replies Latest reply on Sep 11, 2007 7:31 PM by maguskrool

    AS3: Classes, subclasses and "implicit coercion"

    maguskrool Level 1
      Hi.

      I have created several custom classes:
      - Category, containing a string with the category's name.
      - SubCategory, extends Category.
      - CategoryList, containing an array of Category instances and a function getCategoryByName.
      - SubCategoryTracer, with a function subTrace that traces the name of a given SubCategory.

      When I use subTrace, if the argument is a direct SubCategory, it works fine, but if it's the result of getCategoryByName, even when it does return a SubCategory object, I get the following error:
      1118: Implicit coercion of a value with static type tests:Category to a possibly unrelated type tests:SubCategory.

      How can I get this to work? Thanks in advance.