# Loading modules

**URL:** <https://forum.kirupa.com/t/loading-modules/225504>\
**Category:** flash\
**Created:** [May 12, 2007, 10:24pm UTC](https://forum.kirupa.com/t/loading-modules/225504 "2007-05-12T22:24:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Terenced](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@Terenced](https://forum.kirupa.com/u/Terenced)\
**Post date:** [May 12, 2007, 10:24pm UTC](https://forum.kirupa.com/t/loading-modules/225504/1 "2007-05-12T22:24:33Z")

</div>

[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]

```auto

[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]
