动态附加的文本区域抛出错误#1009 - 但类似的标签和文本输入不会
dynamically attached textarea throws Error#1009 - but similar labels and textinputs do not
我场景中的这段代码与评论完美配合:
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;
}
虽然取消注释,但文本区域会抛出错误:
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()
我不明白为什么这不适用于文本区域,因为同样的模式对我适用于标签和文本输入。有什么问题吗?
Flash 组件需要 2 个东西:组件 类 和 当您从其面板拖动组件时添加到库中的组件图形。有些组件需要一些额外的资产,因此如果它们出于某种原因(被错误删除或其他原因)不在库中,可能会导致运行时错误 and/or 非功能性组件。
开发者应始终保持库井井有条!
我场景中的这段代码与评论完美配合:
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;
}
虽然取消注释,但文本区域会抛出错误:
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()
我不明白为什么这不适用于文本区域,因为同样的模式对我适用于标签和文本输入。有什么问题吗?
Flash 组件需要 2 个东西:组件 类 和 当您从其面板拖动组件时添加到库中的组件图形。有些组件需要一些额外的资产,因此如果它们出于某种原因(被错误删除或其他原因)不在库中,可能会导致运行时错误 and/or 非功能性组件。
开发者应始终保持库井井有条!