1 Reply Latest reply on Jun 24, 2007 6:09 PM by peterent

    A question for the experts

      How i do to run a Method in a SWC, was not include in my project, i want to add at run time and execute a method, is possible...?

        • 1. Re: A question for the experts
          peterent Level 2
          In order to run a method on a object at runtime, that object (or class definition and prototype for the class) must be in the Flash Player. There are several ways to get it there.

          One is to compile the definition into the SWF. This is the normal and default way. If your class is in a SWC, you would add the SWC to the library path and its definition will be added to the SWF.

          Another way is to place the SWC into a separate SWF and download the SWF at runtime, bringing the definition into the Flash Player. Only SWFs can be downloaded at runtime, not SWCs. So you need to build a SWF from the SWC. The Flex docs can give you insight about this. You can load the SWF using the Loader, SWFLoader, Modules, and Runtime Shared Libraries.

          There is no magic or simpler way to do this. If you tell the SWF compiler that a class will be defined at runtime, the SWF will contain references to the class, but not the definition. If you try to execute the methods of the class, you will get a runtime error - it will not be automatically downloaded - you will have to write code to do that.