2016-01-14 3 views
-1

У меня есть <mx:Canvas> как мой ApplicationMainView.mxml, и я пытаюсь получить доступ ко всем текущим всплывающим окнам, которые я открыл через него. Есть ли способ сделать это за пределами просмотра каждого дочернего компонента просмотра вручную?найти все всплывающие окна в приложении flex

Моя цель - показать окно входа снова в определенный момент, но есть всплывающие окна, которые будут отображаться в окне просмотра, и пользователь может взаимодействовать с ним. Я хочу попробовать что-то примерно так:

ApplicationMainView.mxml

<mx:canvas> 

<mx:VBox id="containerBox"> 
<!--all view stacks--> 
</mx:VBox> 
</mx:canvas> 

AS3

for each(viewChild in containerBox){ 
    if(viewChild.id != "myLoginView"){ 
     viewChild.visible = false; 
} 
} 

ответ

1

Я думаю, что этот код поможет вам.

public class PopUpUtils 
{ 
    public function PopUpUtils() 
    { 
    } 
    public static function getAllPopups(applicationInstance: Object = null, onlyVisible: Boolean = false): ArrayCollection 
    { 
     var result: ArrayCollection = new ArrayCollection(); 

     if (applicationInstance == null) 
     { 
      // NOTE: use this line for Flex 4.x and higher 
      applicationInstance = FlexGlobals.topLevelApplication; 

      // NOTE: use this line for Flex 3.x and lower 
      //applicationInstance = Application.application; 
     } 

     var rawChildren: IChildList = applicationInstance.systemManager.rawChildren; 

     for (var i: int = 0; i < rawChildren.numChildren; i++) 
     { 
      var currRawChild: DisplayObject = rawChildren.getChildAt(i); 

      if ((currRawChild is UIComponent) && UIComponent(currRawChild).isPopUp) 
      { 
       if (!onlyVisible || UIComponent(currRawChild).visible) 
       { 
        result.addItem(currRawChild); 
       } 
      } 
     } 

     return result; 
    } 
    /** 
    * Checks if an application has visible popups. Only the popups whose base 
    * class is UIComponent are considered. 
    * 
    * @param applicationInstance 
    * Application instance. If null, Application.application is used. 
    * @return True if there are visible popups in the specified application, 
    *   false otherwise. 
    */ 
    public static function hasVisiblePopups(applicationInstance: Object = null): Boolean 
    { 
     if (applicationInstance == null) 
     { 
      // NOTE: use this line for Flex 4.x and higher 
      applicationInstance = FlexGlobals.topLevelApplication; 

      // NOTE: use this line for Flex 3.x and lower 
      //applicationInstance = Application.application; 
     } 

     var rawChildren: IChildList = applicationInstance.systemManager.rawChildren; 

     for (var i: int = 0; i < rawChildren.numChildren; i++) 
     { 
      var currRawChild: DisplayObject = rawChildren.getChildAt(i); 

      if ((currRawChild is UIComponent) && UIComponent(currRawChild).isPopUp 
       && UIComponent(currRawChild).visible) 
      { 
       return true; 
      } 
     } 

     return false; 
    } 
    /** 
    * Closes all the popups belonging to an application. Only the popups 
    * whose base class is UIComponent are considered. 
    * 
    * @param applicationInstance 
    * Application instance. If null, Application.application is used. 
    * @return The list of the closed popups. 
    */ 
    public static function closeAllPopups(applicationInstance: Object = null): ArrayCollection 
    { 
     var allPopups: ArrayCollection = getAllPopups(applicationInstance); 

     for each (var currPopup:* in allPopups) //UIComponent 
     { 
      if (currPopup.id == null) { 
       ObjectUtil.getClassInfo(currPopup) 
       currPopup.automationOwner == DateField 
       flash.utils.getQualifiedClassName(currPopup) 
       PopUpManager.removePopUp(currPopup); 
      } /*else { 
       currPopup.id.displayPopup = false; 
      }*/ 
     } 

     return allPopups; 
    } 
}<br /> 

Получить все всплывающие окна

var arr:ArrayCollection = PopUpUtils.getAllPopups(FlexGlobals.topLevelApplication);