3 Replies Latest reply on Feb 23, 2010 10:04 PM by Flex harUI

    Typecasting a class

    blake_

      Hey, gang--

       

      I need to typecast a class.

       

      Just as an aside, this is a very hard thing to search for effectively. I tried Flex RTTI to no avail.

       

      The situation is, you can pass a class to a function to create an object, like:

       

      public function createObject(aClass: Class): void

      {

      var obj1: aSubClass = new aClass();

      //Do something with obj1

      }

      But my subclasses have permission levels, so I want to say:

      public function createObject(aClass: Class): void

      {

      if(aClass.permissions <= allowedLevel)

      {

      var obj1: aSubClass = new aClass();

      //Do something with obj1

      }

      }

      But since aClass is a Class, it doesn't know form the "permissions" property of my subclass.
      A lot of languages have a way to address specific subclasses. Like, in Smalltalk, you'd have the class Dog vs. the object dog.
      Any thoughts as to how/whether that's done in AS3/FB3?