Sushant
Sushant

Reputation: 635

Close Alert box without object in Flex

I have an application which consists of two states(state1 and state2). Intially state1 popups and then state2 popups. On state2 there are numbers of operations which shows alert. Now if i click logout the State2 window closes and state1 popups but alert still remains popped up,Now i dont have alert object to remove using PopUpmanger.removepopup().

Upvotes: 1

Views: 950

Answers (1)

Mahesh Parate
Mahesh Parate

Reputation: 786

Another workaround you can do, push all alert in to an array if alert is open and if alert is close you can pop it. If alert is open on logout you can get alert object and then you can remove by using PopUpManager.removePopUp() by for loop.

//Global array for your application// 
private var tempArray:Array = new Array();

//When you open first alert
var alert1:Alert = Alert.show("First Alert", "Alert");
tempArray.push(alert1);

//When you open second alert
var alert2:Alert = Alert.show("SecondAlert", "Alert");
tempArray.push(alert2);

//some thing like this.... not tested....

for(var i:int=tempArray.length-1;0< i;i--){
PopUpManager.removePopUp(tempArray[i]);
tempArray.pop();
}

//Below code not tested or

PopUpManager.removeAllPopUps()

or

public function closeAllPopup():void
{
var systemManager:SystemManager = Application.application.systemManager
var childList:IChildList = systemManager.rawChildren
for (var i:int=childList.numChildren-1; i >=0; i– )
{
var childObject:* = childList.getChildAt(i)
if (childObject is UIComponent)
{
var uiComponent:UIComponent = childObject as UIComponent
if (uiComponent.isPopUp)
{
PopUpManager.removePopUp(uiComponent)
}
}
}
}

or check below link: -

http://www.devahead.com/blog/2009/12/getting-all-the-popups-in-a-flex-application/

Upvotes: 1

Related Questions