AS3 MVC Event Listener [Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference

AS3 MVC Event Listener [Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference

我正在使用 MVC 模式,如

所述

http://www.swinburne.edu.au/design/tutorials/P-flash/T-The-Model-View-Controller-Design-Pattern-in-Actionscript-3/ID-144/

然而,对于我的项目,我在 ascii 艺术中使用带有子精灵的视图:

[[menu][ Content ]]

内容容器称为 displayPanelContent

内容精灵使用如下所示的侦听器来使用更新功能:

super.getModel().addEventListener(Event.CHANGE, this.update, false, 0, true);

但是当我尝试使用

删除内容精灵时
while (displayPanelContent.numChildren > 1) {
displayPanelContent.removeChildAt(1);
}

我收到一条错误消息:

[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.

如果我删除侦听器,它会删除得很好,但错误消息非常模糊,我无法辨别错误。

我尽量避免发布代码,因为整个模式和应用程序非常冗长。

一点都不模糊

它清楚地表明您正在对不引用对象的对象引用进行操作,但是null

因此,导致错误的任何行都包含引用 null.

的引用