My app works, but not when I load it into another swf?

I have a map application I’ve built using Flash CS4 and ActionScript 3 .as files. It’s working fine on my local machine. I’m trying to build a preloader for it. My usual way of doing that is to create a shell .swf file which exists just to load the main movie and show the user preloading progress. Unfortunately, whenever I try to load in a movie that uses external .as files, stuff breaks. I’m assuming that it has to do with the LoaderContext and ApplicationDomain, but I’ve tried every ApplicationDomain option, and I always get the same errors.

In my map application, I’ve got a constructor function called Imap() that simply calls an init() function which then sets everything in motion. As I said, when I run the map app, things run smoothly. When I load it into my loader swf, I get (the functions trace out their names as they begin to run):

[FONT=“Courier New”]Imap()
init()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.[domain].imap::Imap/init()
at com.[domain].imap::Imap()[/FONT]

The code in my (as yet uncompleted) preloader swf is:

[FONT=“Courier New”]package
{
import flash.display.;
import flash.system.
;
import flash.net.*;

public class Preloader extends MovieClip
{
	var loader:Loader = new Loader();
	var outline:Sprite = new Sprite();
	var fill:Sprite = new Sprite();
	var w:Number = 100;
	var h:Number = 10;
	var loaderContext:LoaderContext = new LoaderContext()
	public function Preloader()
	{
		loaderContext.applicationDomain = new ApplicationDomain(); 

// I’ve also tried
// new ApplicationDomain(ApplicationDomain.currentDomain),
// ApplicationDomain.currentDomain, and
// new ApplicationDomain(null)
// all to no effect
[…]

		loader.load(new URLRequest("map.swf"), loaderContext);
		addChild(loader);

	}
}

}[/FONT]

This problem has vexed me in the past as well, and I’ve never found a solution for it. If anyone could help me out, that would be great. As an alternative, if anyone would like to suggest a preloading solution that would avoid this whole problem, I would appreciate that as well.

Thanks in advance!