Flex:如何确定 PopUpManager 窗口是否打开(或何时关闭)?

发布于 2024-12-03 08:41:04 字数 256 浏览 1 评论 0原文

在 Flex (Flash Builder 4) 中,我通过 PopUpManager.addPopUp 打开一个新窗口。我的组件中有运行的计时器代码,我需要在该窗口打开时停止计时器,并在窗口关闭时再次启动计时器。

我认为在打开窗口的函数中停止计时器很容易,但是当窗口关闭时如何再次启动计时器?

有没有办法判断我的组件前面是否有弹出窗口,或者特定的弹出窗口是否仍然通过 PopUpManager 打开?

也许事件是更好的方法?

谢谢!

In Flex (Flash Builder 4) I am opening a new window via PopUpManager.addPopUp. I have timer code that runs in my component and I need to stop my timer when that window opens and start the timer again when the window closes.

I figure it's easy enough to stop the timer in the function that opens the window, but how can I start the timer again when the window closes?

Is there a way to tell if there is a pop-up window in front of my component, or if a specific pop-up window is still open via PopUpManager?

Maybe events are a better approach?

Thanks!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

森林很绿却致人迷途 2024-12-10 08:41:04

活动!是要走的路。
发射/关闭期间的火灾事件。在事件处理程序中添加您的逻辑!

Events! is the way to go.
Fire events during launch/close. Add your logic in the event Handlers!

挽清梦 2024-12-10 08:41:04

您可以使用以下代码来检查打开的弹出窗口是否被关闭。
如果它关闭,您可以停止计时器。

  //set the flag to find your popup window is exist or not.
  private var isPopupExist:Boolean = false;

  private function closePopUpWindow():void
  {

   var systemManager:SystemManager = FlexGlobals.topLevelApplication.systemManager;
   //Returns a list of all children.
   var childList:IChildList = systemManager.rawChildren;
   for(var i:int=childList.numChildren-1;i>=0;i--)
   {
      var childObject:* = childList.getChildAt(i);
      //If child object is Uicomponent.
      if (childObject is UIComponent)
      {
      var uiComponent:UIComponent = childObject as UIComponent;
      //If uicomponent is popup and class name is equal to **your popup component name** here i am using "ChatComp".

          if (uiComponent.isPopUp && uiComponent.className == "ChatComp")
          { 
                  isPopupExist = true;
          }
      }
   } 
}

在您的计时器中,

  private function checkPopUpExistance():void
  {
     call closePopUpWindow() function for every 1 sec or any seconds(your wish) to check whether popup is exist or not.
     if(isPopupExist)
     {
       here you stop the timer.
     }
 }

现在您可以在打开弹出窗口时启动计时器。

You can use following code to check whether opened popup window is getting closed or not.
if it is closed you can stop the timer.

  //set the flag to find your popup window is exist or not.
  private var isPopupExist:Boolean = false;

  private function closePopUpWindow():void
  {

   var systemManager:SystemManager = FlexGlobals.topLevelApplication.systemManager;
   //Returns a list of all children.
   var childList:IChildList = systemManager.rawChildren;
   for(var i:int=childList.numChildren-1;i>=0;i--)
   {
      var childObject:* = childList.getChildAt(i);
      //If child object is Uicomponent.
      if (childObject is UIComponent)
      {
      var uiComponent:UIComponent = childObject as UIComponent;
      //If uicomponent is popup and class name is equal to **your popup component name** here i am using "ChatComp".

          if (uiComponent.isPopUp && uiComponent.className == "ChatComp")
          { 
                  isPopupExist = true;
          }
      }
   } 
}

in your Timer,

  private function checkPopUpExistance():void
  {
     call closePopUpWindow() function for every 1 sec or any seconds(your wish) to check whether popup is exist or not.
     if(isPopupExist)
     {
       here you stop the timer.
     }
 }

Now you can start the Timer, when you opened the Popup window.

り繁华旳梦境 2024-12-10 08:41:04

popupmanager是一个单例类,因此您可以轻松地知道使用他的ChildList创建了多少个弹出窗口

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/managers/PopUpManagerChildList.html

The popupmanager is a singleton class, so you can easily know how many popups have been created with his ChildList

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/managers/PopUpManagerChildList.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文