项目渲染器更新时遇到问题

发布于 2024-09-04 17:09:45 字数 715 浏览 9 评论 0原文

我有一个具有 2 个状态的列表 ItemRenderer。当它初始化时,我将其设置为 1 状态并监听将其切换到状态 2 的事件。

protected function onCreationComplete(event:FlexEvent):void{
   currentState = "state1";
   addEventListener(CustomEvent.Event1, switcherfunc);
}

protected function switcherfunc(event:FlexEvent):void{
   currentState = "state2";
}

这 2 种状态之间的区别在于我隐藏/显示了一些标签。

问题是它不起作用。我仍然看到旧状态的视觉效果,即使我Alert.show(currentState),它显示了正确的状态名称。

我尝试在 switch 函数中添加行 invalidateDisplayList(); 但仍然没有成功。

protected function switch(event:FlexEvent):void{
   currentState = "state2";
   invalidateDisplayList();
}

我做错了什么。有什么想法可以让这个 ItemRenderer 真正更新吗?

I have a list ItemRenderer that has 2 states. When it initializes, I set it to 1 state and listen for an event that switches it to state 2.

protected function onCreationComplete(event:FlexEvent):void{
   currentState = "state1";
   addEventListener(CustomEvent.Event1, switcherfunc);
}

protected function switcherfunc(event:FlexEvent):void{
   currentState = "state2";
}

The difference between the 2 states is that I hide/show some labels.

The problem is that it doesn't work. I still see the visual of the old state, even though if I Alert.show(currentState), it shows the correct state name.

I've tried adding the line invalidateDisplayList(); inside the switch function but still no luck.

protected function switch(event:FlexEvent):void{
   currentState = "state2";
   invalidateDisplayList();
}

What am I doing wrong. Any ideas how I can get this ItemRenderer to really update?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文