I get how to load one and only one swf, but how do I load the next?
I’m trying to code something like this.
- Click nav button > preload new section > play in new section
 - Click another nav button > play out old section > preload new section > play in new section
 
Seems simple enough but I’m a big steaming pile of fail. Here’s what I have. I’m throwing out errors and it’s just not pretty. I’ve learned AS twice now. This is my attempt to learn it for the third time. Brace yourself.
import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
// section names in the order that they appear on the nav.
// -------------------------------------------------------------------------------
var sectionArray:Array = new Array(null,"homepage", "photos");
// -------------------------------------------------------------------------------
var firstClick:Boolean = true;
var loader:Loader = new Loader();
function loadSection(num:Number):void {
	
	
	var baseURL:String = "http://www.domain.com/";	// just for testing right now
	var fileToLoad:String = baseURL + sectionArray[num] + ".swf"; // format the name of the section into a path
	
	
	if (firstClick) { // this is the first click
		
		firstClick = false;
		
		addChild(loader);
   	 	loader.load(new URLRequest(fileToLoad));
		
		loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
		
		function loadProgress(event:ProgressEvent):void {
			var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
			percentLoaded = Math.round(percentLoaded * 100);
			trace("Loading: "+percentLoaded+"%");
		}
		
		function loadComplete(event:Event):void {
			
			trace("Loading Complete :" + fileToLoad);
			loader.content.initIn(); // play the loaded content in
	
		}
		
	} else { // this is the second (or more) click
	
		loader.content.initOut(); // play OLD content out
		
		addEventListener(Event.ENTER_FRAME,checkPlayOutOfSWF);  
		
		function checkPlayOutOfSWF(event:Event) {  
			
			// watch the content and check to see when it hits the last frame on the timeline
   			if (loader.content.currentFrame == loader.content.totalFrames) {
				
				
				// when the old centent plays out start the preloader for the NEW content
   	 			loader.load(new URLRequest(fileToLoad));
				loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
				loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
				
				function loadProgress(event:ProgressEvent):void {
					var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
					percentLoaded = Math.round(percentLoaded * 100);
					trace("Loading: "+percentLoaded+"%");
				}
				
				function loadComplete(event:Event):void {
					
					trace("Loading Complete :" + fileToLoad);
					loader.content.initIn(); // play the NEW content in
					removeEventListener(Event.ENTER_FRAME, checkPlayOutOfSWF);
			
				}
		
				
			} 
			
		}
		
		
	}
	
}
I’ve seen a thousand threads about “how do I preload a file.” But I’ve never seen one that takes into account that a site will ultimately have multiple files (sections).
Can you help?