本文介绍了如何关闭所有弹出窗口中的Flex?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想告诉所有的弹出窗口(已弹出,单独关闭)的图像由pressing按钮preSS,并希望结束对另一个按钮preSS所有这些窗口。任何帮助是AP preciated。
I want to show all popup windows(already popped up and closed individually) on an image by pressing a button press and want to close all those windows on another button press. Any help is appreciated.
推荐答案
试试这个:
package com.devahead.utils
{
import flash.display.DisplayObject;
import mx.collections.ArrayCollection;
import mx.core.Application;
//import mx.core.FlexGlobals; // NOTE: use this import for Flex 4.x and higher
import mx.core.IChildList;
import mx.core.UIComponent;
import mx.managers.PopUpManager;
public class PopUpUtils
{
/**
* Returns all the popups inside an application. Only the popups whose base
* class is UIComponent are returned.
*
* @param applicationInstance
* Application instance. If null, Application.application is used.
* @param onlyVisible
* If true, considers only the visible popups.
* @return All the popups in the specified application.
*/
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: UIComponent in allPopups)
{
PopUpManager.removePopUp(currPopup);
}
return allPopups;
}
}
}
我把它从以下方面:的
I got it from the following:http://www.devahead.com/blog/2009/12/getting-all-the-popups-in-a-flex-application/
这篇关于如何关闭所有弹出窗口中的Flex?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!