溝通,我在一個項目中,如果母公司是從影片剪輯中調用一個孩子從幼兒到父SWF通信掙扎。從兒童SWF
父影片剪輯有這樣的行動層
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");
}
孩子SWF已驗證碼發送到父:
centre_btn.addEventListener(MouseEvent.MOUSE_DOWN, childBtn_mouseDownHandler);
// thanks to "Florent" for this code.
function childBtn_mouseDownHandler(event:MouseEvent) {
dispatchEvent(new Event("directions"));
}
我返回我的錯誤是:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
從您的示例中,不清楚哪一行代碼導致此錯誤。當在子SWF中單擊該按鈕時,childLoader_someSignalHandler()中的代碼是否被執行? – 2012-08-10 16:06:01
答案在於下面的評論,這是一個問題,沒有泡沫設置爲「真實」的孩子,並有一個多餘的內容。在父級的addEventListener中。 – Neilisin 2012-08-10 16:58:39