[求助] flex项目,AS3.0使用自定义的itemRenderer出错

baidu_32584951 2015-11-05 04:46:55
各位大神好,现在做的一个flex项目中,需要用到ComboBox组件实现一个功能:每一个Item要有一个textinput和一个button,在textinput里面输入字符串,回车后变更item的内容,button的作用是删除当前的item,本人初学,并不是很懂,希望大神们帮忙。
下面是部分代码
public class ComboBoxItemRenderer extends VBox
{
private var texti:TextInput;
private var button:Button;
private var hgrop:HGroup;

override protected function createChildren():void
{
hgrop = new HGroup;
hgrop.height = 25;
hgrop.percentWidth = 100;
hgrop.horizontalAlign = "left";
addElement(hgrop);


}

public function ComboBoxItemRenderer()
{
super();
//comboboxItems();
}

public function comboboxItems():void
{
var but:Button = new Button;
but.label = data.label;
but.buttonMode = true;
but.addEventListener(MouseEvent.CLICK,this.parentDocument.cbiButtonClick);

var ti:TextInput = new TextInput;
ti.text = data.text;
ti.editable = true;
ti.addEventListener(FlexEvent.ENTER,this.parentDocument.cbiTextInputEnter);

}

override protected function commitProperties():void
{
super.commitProperties();


if(data.text != ""){
texti = new TextInput();
texti.text = data.text;
texti.editable = false;
texti.percentHeight = 100;
texti.percentWidth = 95;
hgrop.addElement(texti);
}else if(data.text == ""){
texti = new TextInput();
texti.editable = true;
texti.prompt = "请输入情景名";
texti.percentHeight = 100;
texti.percentWidth = 95;
//texti.addEventListener(FlexEvent.ENTER,this.parentDocument.parentDocument.cbiTextInputChange());
//texti.addEventListener(FocusEvent.FOCUS_OUT,this.parentDocument.parentDocument.chiTextInput2Change());
hgrop.addElement(texti);
}
if(data.label != ""){
button = new Button();
button.label = data.label;
button.width = 15;
button.height = 15;
//button.addEventListener(MouseEvent.CLICK,this.parentDocument.parentDocument.cbiButtonCilck(event));
hgrop.addElement(button);
}
}
}

但是现在有一些问题,不知道是什么原因,还有就是点击button的时候希望能不出发selectedchange事件,

TypeError: Error #1009: 无法访问空对象引用的属性或方法。
at spark.components::Scroller/focusInHandler()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Scroller.as:2139]
at flash.display::Stage/set focus()
at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::setFocus()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\ContainerController.as:2265]
at flashx.textLayout.container::ContainerController/mouseDownHandler()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\ContainerController.as:2067]
at flashx.textLayout.container::TextContainerManager/mouseDownHandler()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\TextContainerManager.as:1939]
at spark.components.supportClasses::RichEditableTextContainerManager/mouseDownHandler()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\supportClasses\RichEditableTextContainerManager.as:666]
at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::requiredMouseDownHandler()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\ContainerController.as:2088]
at flashx.textLayout.container::TextContainerManager/mouseDownHandler()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\TextContainerManager.as:1936]
at spark.components.supportClasses::RichEditableTextContainerManager/mouseDownHandler()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\supportClasses\RichEditableTextContainerManager.as:666]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:13152]
at mx.managers::SystemManager/mouseEventHandler()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemManager.as:2918]
这个问题不知道是为何触发,求解决方法
...全文
429 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
baidu_32584951 2015-11-06
  • 打赏
  • 举报
回复
各位大神求帮助啊
baidu_32584951 2015-11-05
  • 打赏
  • 举报
回复
大神快来!!!

4,328

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计 Flex
社区管理员
  • Flex
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧