Hi, I’m an experienced programmer but new to Flash 9 and ActionScript 3.0 - hope this isn’t a stupid question, but I’ve searched and searched and can’t find a solution :h: …
I created what I think is a fairly typical full Flash site, with a main.swf which contains the skin and menus, then each menu button loads an external .swf (e.g. welcome.swf for the first option) using a Loader object.
This was working fine until I tried to make my external .swf’s more intelligent by adding script as a DocumentClass. e.g. gallery.swf declares GalleryDocumentClass as its document class.
Now when I compile & run the project (or main.swf) I get the following error when I click on the Gallery menu item, and the actionscript terminates:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at GalleryDocumentClass$iinit()
What am I doing wrong? Is it possible to load an external .swf that uses DocumentClass? Surely this must be something stupid I’m missing!
My Loader code (currently in the first frame of main.swf) is as follows:
function loadContent([url:String](http://www.kirupa.com/forum/String), container:DisplayObjectContainer):void {
var loader:Loader = new Loader();
var loaderInf:LoaderInfo = loader.contentLoaderInfo;
loader.load(new URLRequest(url));
loader.visible = false;
addChild(loader);
var myProgressBar:ProgressBar = new ProgressBar();
myProgressBar.source = loaderInf;
myProgressBar.move(myLabel.x, myLabel.y + myLabel.height);
myProgressBar.addEventListener(Event.COMPLETE, function(event:Event) {
container.removeChild(myProgressBar);
container.removeChild(myLabel);
container.addChild(loader.content);
TransitionManager.start(MovieClip(container), {type:Fade, direction:Transition.IN, duration:1, easing:Strong.easeOut});
});
container.addChild(myProgressBar)
}
The file GalleryDocumentClass.as contains the code:
package {
import flash.display.Bitmap;
/* more imports... */
public class GalleryDocumentClass extends MovieClip {
/* etc... */
}
/* etc... */
}
As I said, my loader works fine with plain .swf files with no DocumentClass, but as soon as I add a class I get the error… also get the error if I omit the DocumentClass but the .swf references library objects which are backed by a custom class.
A classpath problem?
Thanks for any help!