Adobe Flex PopUpManager - 打开的 TitleWindow 的多个实例
设置:我的 Flex 应用程序是由多个“子应用程序”组成的应用程序。基本上,主应用程序区域是一个 ApplicationControlBar,其中包含每个子应用程序的按钮。该区域的其余部分是显示子应用程序的画布。一次只能看到一个子应用程序。当在子应用程序之间切换时,我们执行canvas.removeAllChildren(),然后执行canvas.addChild(subAppSwitchedTo)。它本质上是 ViewStack 的手动实现(其优缺点不是本文的主题,因此不要对此发表评论)。
问题:在我的一个子应用程序(假设子应用程序“A”)中,我有一个搜索功能,结果显示在弹出的 TitleWindow 中。工作流程就像输入搜索条件,单击搜索按钮,标题窗口弹出结果(多选数据网格),选择所需的结果,单击确定,弹出窗口消失(PopUpManager.removePopUp),然后继续工作。这一切都很好。问题是,如果我切换到不同的子应用程序(例如“B”——其中 A 获得removeAllChildren(),并且 B 被添加),然后切换回到 A再次搜索,当结果TitleWindow弹出时,将有TWO堆叠在一起。如果我继续导航离开并返回到 A,每次搜索时,弹出窗口“堆栈”中都会有一个额外的弹出窗口(每次 A 获取 addChild()'d 时就会出现一个弹出窗口)。
还有其他人经历过吗?我不知道该怎么办,它在我的应用程序中造成了严重的可用性错误。这会给任何人敲响警钟吗?就像我需要以某种方式刷新 PopUpManager 或其他东西(即使我正确地调用了 removePopUp() 来删除 TitleWindow)。请帮忙!
编辑
Flex SDK = 4.5.1
// Subapp "A"
if (!certificateSearchTitleWindow)
{
certificateSearchTitleWindow = new CertificateSearchTitleWindow;
certificateSearchTitleWindow.addEventListener("searchAccept", searchOKPopupHandler);
certificateSearchTitleWindow.addEventListener("searchCancel", searchClosePopupHandler);
}
PopUpManager.addPopUp(certificateSearchTitleWindow, this, true);
Setup: My Flex application is one consisting of several "subapps". Basically, the main application area is an ApplicationControlBar with buttons for each of the subapps. The rest of the area is a canvas where the subapps are displayed. Only one subapp is visible at a time. When switching between subapps, we do a canvas.removeAllChildren(), then canvas.addChild(subAppSwitchedTo). It's essentially a manual implementation of a ViewStack (the pros and cons of which are not the topic of this, so refrain from commenting on this).
Problem: In one of my subapps (let's say subapp "A"), I have a search function where results are displayed in a TitleWindow that gets popped up. Workflow is like enter search criteria, click search button, TitleWindow pops up with results (multiple selection datagrid), choose desired result(s), click OK, popup goes away (PopUpManager.removePopUp), and continue working. This all works fine. The problem is if I switch to a different subapp (say "B" -- where A gets removeAllChildren()'d and B gets added), then switch back to A and search again, when the results TitleWindow pops open, there will be TWO stacked on top of each other. If I continue to navigate away and back to A, every time I search, there will be an additional popup in the "stack" of popups (one for each time A gets addChild()'d).
Has anyone else experienced this? I'm not sure what to do about it and it's causing a serious usability bug in my application. Does this ring any bells to anyone? It's like I somehow need to flush the PopUpManager or something (even though I'm correctly calling removePopUp() to remove the TitleWindow). Please help!
EDIT
Flex SDK = 4.5.1
// Subapp "A"
if (!certificateSearchTitleWindow)
{
certificateSearchTitleWindow = new CertificateSearchTitleWindow;
certificateSearchTitleWindow.addEventListener("searchAccept", searchOKPopupHandler);
certificateSearchTitleWindow.addEventListener("searchCancel", searchClosePopupHandler);
}
PopUpManager.addPopUp(certificateSearchTitleWindow, this, true);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的猜测是,当您删除其父项( PopUpManager.addPopup() 方法中的 this )时,弹出窗口将从主显示列表中删除,但不会从其父显示列表中删除。为什么不在子应用程序中监听 Event.REMOVED 事件,然后删除弹出窗口?那将是:
My guess is that the popup is removed from the main display list when you remove its parent (this in the PopUpManager.addPopup() method), but not from its parent display list. Why don't you listen, in your subapps, to the Event.REMOVED event, and then remove your popup ? That would be :
感谢那些提出建议的人。事实证明我一遍又一遍地重新注册事件监听器。
我使用 singleton 充当子应用程序之间的“共享内存”。我在子应用 A 的 creationComplete 回调中设置
singleton.addEventListener(someType,listener)
。因此,每次我导航回 A 时,creationComplete 都会运行并重新添加此侦听器。搜索后,侦听器方法(打开弹出窗口)被多次调用,即与添加事件的次数一样多。外部参考:http://forums.adobe.com/message/3941163
Thank you to those who gave suggestions. It turned out I was re-registering an eventListener over and over.
I am using a singleton to act as "shared memory" between the subapps. I was setting
singleton.addEventListener(someType, listener)
in subapp A's creationComplete callback. So everytime I navigated back to A, the creationComplete was running and re-adding this listener. After the search, the listener method (that opened the popup) was being called multiple times, i.e., as many times as the event had been added.xref: http://forums.adobe.com/message/3941163