Preloader Woes

H’lo folks, I hope your day is treating you well.

I’ve been working on my first game for a while now, and I’m trying to get all of the basics done and finished with so I don’t have to worry about them in the future. I’ve been spending the past few days pulling my hair out on my preloader. It’s the same old problem everyone has (preloader doesn’t display until it’s at 100%), but despite all the places I’ve looked, all the resources I’ve tapped and all the changes I’ve implemented, I still can’t make it work. So, here’s what I’ve got.

First, a disclaimer to get the obvious out of the way: I have absolutely no assets in my FLA (so obviously there’s nothing exported to the first frame). Everything is generated by code.

So, where I’m at: I have a TestGameFLA.fla with two frames. The first frame is absolutely empty and the second has nothing except for a single line of code in it’s actions. The .fla links to the document class which contains the following code:

	import flash.display.MovieClip;
	import GameShell.Preloader.*;
	public class TestGamePreload extends MovieClip
		private var thisPreloader:Preloader;
		public function TestGamePreload():void
			thisPreloader = new Preloader(loaderInfo);
			thisPreloader.addEventListener(PreloaderEvent.FINISH, preloadDone);
		private function preloadDone(doneEvent:PreloaderEvent):void
			thisPreloader.removeEventListener(PreloaderEvent.FINISH, preloadDone);
			thisPreloader.addEventListener(PreloaderEvent.DESTROY, preloadGone);
		private function preloadGone(goneEvent:PreloaderEvent):void
			thisPreloader.removeEventListener(PreloaderEvent.DESTROY, preloadGone);
			thisPreloader = null;

Suffice it to say that I have thoroughly tested my Preloader class and it accurately updates itself graphically (well, once it loads itself anyway…) and dispatches the two event types when you’d expect (FINISH once loading is done and DESTROY once it’s completed a removal animation and nullified all of its data). It’s also worth noting that this class contains absolutely no references to any data except the preloader itself, so it would seem I’ve overcome the hurdle of assets in your document class being loaded before anything else.

So, to finish the story, once we get to frame 2, it’s line of code executes:

addChild(new TestGameAS(stage)); is another actionscript file in the same folder with the following contents:

	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import GameShell.GameData.*;
	import GameShell.GameData.TestGameData.*;
	public class TestGameAS extends MovieClip
		private var thisStage:DisplayObject;
		private var thisData:GameData;
		private var thisGame:GameShell;
		public function TestGameAS(newStage:DisplayObject):void
			thisStage = newStage;
			thisData = new TestGameData(thisStage);
			thisGame = new GameShell(thisData);

The Data class is just something I use to store information like possible player actions, default key bindings, earnable achievements, etc… The GameShell class uses that data to create the game itself. Once again, I can assure you that these two classes are thoroughly tested and functioning as intended.

So there it is, the age old problem of how to make your preloader load before the rest of your data. Does anyone have any insight as to what I might be missing?

Thank you so much in advance for your time and effort in this matter.

I’m sorry, I forgot to mention one of the steps I’d taken, which is the use of a separate swf which loads the main one using a Loader class. Unfortunately this option is not available to me since any website I’d submit to requires their games to be represented within a single swf and I don’t have the ability to host any files.

A postscript, just for the sake of completeness:
My final swf is currently sitting at 41kb.
I’m using Adobe Flash CS3 Professional.
I’m testing by simulating download with settings 14.4 (1.2 kb/s)
The following is the full documentation of my Preloader class (just in case)

	This is a class which holds a Preloader.  It is constructed with a LoaderInfo object and uses that
	  data to indicate its progress and to give the user an option to continue once it is finished.
	Public Static Constants:
	Private Variables:
		thisLogic Helper class designed to do the thinking.
		thisGraphics Helper class designed to provide the input and output.
	Public Functions

			Constructor which takes a LoaderInfo and uses its data and progress to create a Preloader.
			@param dataTransfer the LoaderInfo whose load progress we wish to display
			@pre dataTransfer is a LoaderInfo
			@post a new Preloader has been created and is running
			Initiates the process of a complete removal of all data within this Object.
			@pre true
			@post No data exists within this Object.
	Private Functions initiating from user generated events:
			This method is called when thisGraphics has told the user that preloading is done and the
			  user has stated their desire to progress past the preloader.  This information is then
			  dispatched to any listener.
			@param readyEvent the event generated by thisGraphics
			@pre the user is wanting to progress past the preloading phase
			@post this desire is dispatched to any listeners
	Events Dispatched:
			Generated: When this Preloader has removed all references to all data.
			Contains:  No data.
			Use:       Not applicable
			Generated: When loading has fully completed and the user has indicated that they
					   are aware of this and would like to progress past the preloader phase.
			Contains:  No data.
			Use:       Not applicable.
	Errors Thrown:
		PreloaderError I.D. #1
			When a new Preloader is created with a parameter other than a LoaderInfo
		PreloaderError I.D. #2
			When a PreloaderEvent is generated with a type and eventData of incompatable dataTypes
			-type PreloaderEvent.LOAD_UPDATE requires Number eventData
			-type PreloaderEvent.FINISH requires null eventData
			-type PreloaderEvent.DESTROY requires null eventData
			-types not listed above are not supported
		PreloaderError I.D. #3
			When a data request is made to an event type that it does not support.
			-type PreloaderEvent.LOAD_UPDATE supports Number eventData
			-type PreloaderEvent.FINISH supports null eventData
			-type PreloaderEvent.DESTROY supports null eventData