1 Reply Latest reply on May 13, 2007 8:53 AM by [Reider]

    Loading modules

    [Reider]
      I'm planning to make swf files that can access classes inside my main swf that loaded them but I don't want to get any errors when trying them outside the main swf.

      My first idea was to make an Interface that stores the invoke able methods and load the classes in dynamically like this:

      var m_class:String = "com.utils.UtilManagger";
      var managge:UtilInterface = getDefinitionByName(m_class).getInstance()

      In this case I also had to make an empty UtilManagger class with all the functions to avoid any compile errors.


      package com.utils
      {
      public class UtilManagger implements UtilInterface
      {
      public function getNum():int{
      return null
      }

      public function setNum(num:int):void{
      }

      public static function getInstance():UtilManagger{
      return new UtilManagger()
      }
      }
      }


      And of course the real UtilManagger is compiled into the main swf and it is a Singleton class to provide me with dispatch able events that the modules can register to.


      Is there any better way to make swf-s that can use services provided by the loader swf?