0 Replies Latest reply on Mar 6, 2008 9:50 PM by stephenkawaguchi

    Flash SWC in Flex

      I'm having trouble understanding how a Flash CS3 SWC gets used in Flex, and specifically how I instantiate SWC classes in Flex. So: I have an SWC acting as an asset library. I have a function in my AS class that loads a class into a pre-defined movieclip. When I run that function initially in Flex, it doesn't work:

      <MyComps:Character id="character" x="300" y="100" />


      When I instantiate the class that I'm trying to load in Flex, and then run my AS function, it works fine.

      <MyComps:Character id="character" />

      <MyComps:Outfit_1_pants />
      <MyComps:Outfit_1_shirt />


      The setOutfit function is essentially doing this:
      var ClassReference:Class = getDefinitionByName(id) as Class;
      var instance:Object = new ClassReference();

      where 'id' is something like "Outfit_1_shirt"

      So basically I get that I'm loading all of my classes in my swc, but I don't get why calling them in AS doesn't instantiate them. I'd rather avoid loading all of the assets in the swc right away because there will be a lot. Is there some sort of command that will let me tell Flex to instantiate my class at runtime properly??

      Thanks in advance!