Okay… now my knowledge of AS3 is beginning to be stretched
I’ve written my basic game engine that has separate SWF files for each “level”. Now I’m looking at creating a single SWF that will load in each level as required, and provide basic common UI controls such as score, mouse cursor and so forth.
The level SWF has a custom document class, GameStage, that will be common to all the level SWFs and contains all the code and support classes to let the player move about the level etc. The SWF file contains both manually placed MovieClip content as well as dynamic, scripted-only content.
Here’s my code to test just loading the game SWF into the “global” SWF:
var gameLoader:Loader = new Loader();
gameLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
gameLoader.load(new URLRequest('FirstLevel.swf'));
function completeHandler(evt:Event)
{
//addChild(gameLoader);
}
I’ve commented out the addChild line for the time being, but it seems even the simple act of loading the level SWF throws me a:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at GameStage()
However, the level SWF on its own works perfectly - it’s only when loaded by the second SWF that the null reference error occurs.
I took at look at
http://www.kirupa.com/forum/showthread.php?p=2123134 - is this relevant to the issue?
Unfortunately the error Flash is throwing me is not a very helpful one, akin to “Well, something went wrong” - no, really?
I figure that it’s something I haven’t grasped properly yet, or need to add to make Flash happy. Thoughts? More information needed?