[COLOR=black][FONT=Arial]I’m just wondering what’s the best way to acces classes from a loaded swf. [/FONT][/COLOR]
[COLOR=black][FONT=Arial]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.[/FONT][/COLOR]
[COLOR=black][FONT=Arial]My first idea was to make an Interface that stores the invoke able methods and load the classes in dynamically like this:[/FONT][/COLOR]
[COLOR=black][FONT=Arial]var m_class:String = “com.utils.UtilManagger”;[/FONT][/COLOR]
[COLOR=black][FONT=Arial]var managge:UtilInterface = getDefinitionByName(m_class).getInstance()[/FONT][/COLOR]
[COLOR=black][FONT=Arial]In this case I also had to make an empty UtilManagger class with all the functions to avoid any compile errors.[/FONT][/COLOR]
[COLOR=black][FONT=Arial]package com.utils[/FONT][/COLOR]
[FONT=Arial][COLOR=black]{[/COLOR][/FONT]
[FONT=Arial][COLOR=black]public class UtilManagger implements UtilInterface[/COLOR][/FONT]
[FONT=Arial][COLOR=black]{[/COLOR][/FONT]
[FONT=Arial][COLOR=black] public function getNum():int{[/COLOR][/FONT]
[FONT=Arial][COLOR=black] return null[/COLOR][/FONT]
[FONT=Arial][COLOR=black] }[/COLOR][/FONT]
[FONT=Arial][COLOR=black] public function setNum(num:int):void{[/COLOR][/FONT]
[FONT=Arial][COLOR=black] }[/COLOR][/FONT]
[FONT=Arial][COLOR=black] public static function getInstance():UtilManagger{[/COLOR][/FONT]
[FONT=Arial][COLOR=black] return new UtilManagger()[/COLOR][/FONT]
[FONT=Arial][COLOR=black] }[/COLOR][/FONT]
[FONT=Arial][COLOR=black]}[/COLOR][/FONT]
[FONT=Arial][COLOR=black]}[/COLOR][/FONT]
[COLOR=black][FONT=Arial]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.[/FONT][/COLOR]
[COLOR=black][FONT=Arial]Is there any better way to make swf-s that can use services provided by the loader swf?[/FONT][/COLOR]