删除监听器
我已经阅读了如何做到这一点,但我在实施方面还不够。我希望 updateComplete 事件运行一次,然后删除侦听器。
这是组件:
<mx:ComboBox
id="templatesCombo"
dataProvider="{lendersModel.fileTemplateComposites}"
prompt="Select Template"
width="200"
labelFunction="getTemplateName"
change="onViewTempComboChange(event)"
updateComplete="checkTemplatesLength(event);"/>
这是处理程序:
private function checkTemplatesLength( event:FlexEvent ):void{
if( lendersModel.fileTemplateComposites.length == 1 ){
this.templatesCombo.selectedIndex = 1;
this.currentFileTemplate = templatesCombo.selectedItem as FileTemplateCompositeDTO;
this.templateActions_bb.updateButtonVisibility( 2, true ); // disable delete button
}
var cb:ComboBox = ComboBox( event.currentTarget )
cb.removeEventListener( FlexEvent.UPDATE_COMPLETE, checkTemplatesLength );
}
我缺少什么?我认为这就是我在这里阅读的其他帖子中的做法。
任何提示将不胜感激。
谢谢!
I've read how to do this but I'm falling short on implementation. I want an updateComplete event to run once then remove the listener.
Here's the component:
<mx:ComboBox
id="templatesCombo"
dataProvider="{lendersModel.fileTemplateComposites}"
prompt="Select Template"
width="200"
labelFunction="getTemplateName"
change="onViewTempComboChange(event)"
updateComplete="checkTemplatesLength(event);"/>
Here's the handler:
private function checkTemplatesLength( event:FlexEvent ):void{
if( lendersModel.fileTemplateComposites.length == 1 ){
this.templatesCombo.selectedIndex = 1;
this.currentFileTemplate = templatesCombo.selectedItem as FileTemplateCompositeDTO;
this.templateActions_bb.updateButtonVisibility( 2, true ); // disable delete button
}
var cb:ComboBox = ComboBox( event.currentTarget )
cb.removeEventListener( FlexEvent.UPDATE_COMPLETE, checkTemplatesLength );
}
What am I missing? I thought this is how to do it from other posts I've read here.
Any tips will be greatly appreciated.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许它一开始就没有作为事件侦听器附加?!但我确信它是这样工作的:
maybe it's not attached as an event listener in the first place?! but i'm sure it works this way: