PDA

View Full Version : Closing a component window...


VandenTR
09-13-2006, 03:47 PM
Hello,

I've got a non-modal component window that opens with an on(Press) function and closes when hitting the 'X' button as it should.

The problem I'm facing is how to eliminate the first window when somebody hits the button a second time. Right now it opens a new window instance on every click, I want it to allow only one at a time...

Best Regards,
TVB

btn_healthy.onPress = function() {

var indexWindow = PopUpManager.createPopUp(_root, Window, false,
{closeButton:true, title:"Title...", contentPath:""});
indexWindow.setSize(200,200)
indexWindow._x=275;
indexWindow._y=115;

var iwListener:Object = new Object();
iwListener.click = function(evt:Object) {
evt.target.deletePopUp();
};
indexWindow.addEventListener("click", iwListener);
}

mcmcom
09-13-2006, 04:21 PM
does that PopupManager allow you to see what popups are open, why not just check to see if a movieClip with the name of your popup exists and is visible? if it is then dont allow another one to be created. Or even simpler just create a boolean value like popupOpen = true and set that when the button opens the first popup, include code in the button like :


btn_healthy.onPress = function() {
if(popupOpen == false){
var indexWindow = PopUpManager.createPopUp(_root, Window, false,
{closeButton:true, title:"Title...", contentPath:""});
indexWindow.setSize(200,200)
indexWindow._x=275;
indexWindow._y=115;

var iwListener:Object = new Object();
iwListener.click = function(evt:Object) {
evt.target.deletePopUp();
};
indexWindow.addEventListener("click", iwListener);
popupOpen = true;
}else{
trace("popup already open");
}

hth,
mcm