I'm struggling with communicating from a child to parent SWF in a project, where the parent is calling a child from within a movieclip.
The parent movieclip has this in the actions layer
var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest("child.swf");
loader.load(defaultSWF);
//I'm using an if statement to check if the movieclip is loaded to stage
if (loader.parent != null) {
loader.dispatchEvent(new Event(Event.ADDED_TO_STAGE));
trace("loader added to stage"); // trace returns positive
loader.content.addEventListener("directions", childLoader_someSignalHandler);
}
//once a button in the child SWF is clicks the playhead will
//change position on the parent.
function childLoader_someSignalHandler(event:Event):void {
gotoAndStop("directions");
}
The child SWF has this code sending to the parent:
centre_btn.addEventListener(MouseEvent.MOUSE_DOWN, childBtn_mouseDownHandler);
// thanks to "Florent" for this code.
function childBtn_mouseDownHandler(event:MouseEvent) {
dispatchEvent(new Event("directions"));
}
The error I'm being returned is:
TypeError: Error #1009: Cannot access a property or method of a null object reference.