Actionscript 3 动态附加的textarea会抛出错误#1009-但类似的标签和TextInput不会

Actionscript 3 动态附加的textarea会抛出错误#1009-但类似的标签和TextInput不会,actionscript-3,Actionscript 3,“我的场景”中的这段代码与注释配合得非常好: import state; import fl.controls.TextInput; import fl.controls.TextArea; import flash.events.TextEvent; state.data.newNotice = new Object(); state.data.newNotice.title=''; state.data.newNotice.text=''; var noticeTitleInput:Te

“我的场景”中的这段代码与注释配合得非常好:

import state;
import fl.controls.TextInput;
import fl.controls.TextArea;
import flash.events.TextEvent;

state.data.newNotice = new Object();
state.data.newNotice.title='';
state.data.newNotice.text='';

var noticeTitleInput:TextInput = new TextInput();
noticeTitleInput.width = noticeTitleEditor.width;
noticeTitleInput.height = noticeTitleEditor.height;
noticeTitleInput.text = '';
noticeTitleInput.setStyle("textFormat", state.data.fontFormat);
noticeTitleEditor.addChild(noticeTitleInput);

noticeTitleInput.addEventListener(TextEvent.TEXT_INPUT, onInput);

/*var noticeTextInput:TextArea = new TextArea();
noticeTextInput.wordWrap = true;
noticeTextInput.width = noticeEditor.width;
noticeTextInput.height = noticeEditor.height;
noticeTextInput.text = '';
noticeTextInput.setStyle("textFormat", state.data.fontFormat);
noticeEditor.addChild(noticeTextInput);

noticeTextInput.addEventListener(TextEvent.TEXT_INPUT, onInput);*/

function onInput(event:TextEvent):void {
    state.data.newNotice.title = noticeTitleInput.text;
//  state.data.newNotice.text = noticeTextInput.text;
}
尽管取消注释,但textarea会抛出一个错误:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at fl.controls::TextArea/drawLayout()
    at fl.controls::TextArea/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::BaseButton/draw()
    at fl.core::UIComponent/drawNow()
    at fl.controls::ScrollBar/draw()
    at fl.controls::UIScrollBar/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::BaseButton/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::LabelButton/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::BaseButton/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::BaseButton/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::BaseButton/draw()
    at fl.core::UIComponent/drawNow()
    at fl.controls::ScrollBar/draw()
    at fl.controls::UIScrollBar/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::BaseButton/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::LabelButton/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::BaseButton/draw()
    at fl.core::UIComponent/callLaterDispatcher()
TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/addChildAt()
    at fl.controls::BaseButton/drawBackground()
    at fl.controls::BaseButton/draw()
    at fl.core::UIComponent/callLaterDispatcher()

我不明白为什么这不适用于文本区域,因为相同的模式适用于我的label和textinput。有什么问题吗?

Flash组件需要两件事:组件类和从面板拖动组件时添加到库中的组件图形。某些组件需要大量额外的资源,因此,如果它们由于任何原因(错误删除或其他原因)而不在库中,则可能会导致运行时错误和/或非功能组件


开发人员应该始终保持库的组织

您是否将TextArea组件添加到库中?看起来你导入的类实际上没有将相关组件添加到项目的库中。带有链接到
fl.controls.TextArea
-是的,它在我的库中。我只是随便看看。起初,它在清洁测试中运行良好。然后我发现,如果从库中删除组件资产/TextAreaSkins/TextArea_upSkin,则会出现drawLayout#1009错误。我想还有其他东西可能会遗漏,从而产生其他错误。我建议您清理库并重新导入控件的资产。@Organi请将此作为答案重新发布。我不知道我是怎么搞砸了textArea的,因为我只是把它拖到舞台上一次,看看它是什么样子。但就是这样。在重新导入时工作正常。