I'm a newbie flex developer so I'm hoping someone with more experience
will have some insight into my problem.

I have an application that has a canvas which contains icons for
different tools. The icons are within canvases that I disable when the
users clicks on them. Also when the canvas is clicked on a new pop-up
opens and the currently opened one closes (moves off screen). On the
pop-ups there are different components (buttons, combo boxes,
datagrids). Everything works wonderfully if there is only one set of
clicks on the pop-up, such as selecting from the combobox and clicking
on the button. But if there are multiple clicks the Close event doesn't
fire off and the pop-up isn't removed. So if I select from the combobox
and click the button more than once it doesn't work.
But I can close it by clicking the close button...but sometimes that
doesn't even work. Also, after a pop-up is not closed because of
multiple clicks, clicking on a 3rd tool will close the one that didn't
close when the 2nd tool was clicked on. Clicking a 4th tool will close
the 2nd one and so on, it's like it skips one and then is one behind.
Does that make sense?

I hope I can explain this well enough and hopefully I haven't written
really confused code. The tools are in the main application which calls
an action script that opens the pop-up. The pop-ups have different
options for searches and return the results in another pop-up. When a
new tool icon is clicked all open pop-ups close.

In my actionscript file which opens the pop-up:
private function openListPop():void
{
   // Close all open pop-ups
   closePopups();

   // Open pop-up
   winList= FindHOA(PopUpManager.createPopUp(this, FindHOA, false,
PopUpManagerChildList.POPUP));
   winList.x = Application.application.SearchCanvas.x - 350;
   winList.y = 85;
   winList.addEventListener(CloseEvent.CLOSE, closeListPop, false, 0,
true);
}

protected function closeListPop(event : CloseEvent) : void
{
  // Make button in toolbar clickable again
  FindListCan.enabled=true;
  winList.removeEventListener(CloseEvent.CLOSE, closeListPop);
}

Each pop-up implements the following:

package components
{
  import mx.core.IFlexDisplayObject;
  import mx.events.CloseEvent;

  public interface iPopup extends IFlexDisplayObject
  {
   function closeWindow():void;
  }
}

In the pop-up closeWindow function I have:

public function closeWindow():void
  {
   PopUpManager.removePopUp(this);
   pop1.dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
  }

Pop1 is a pop-up launched from the 1st pop-up and displays the results
of a query:

private function showPop(content:String, ... args):void
{
   if ( pop1 == null )
   {
    // pop up is NOT already open
    pop1 = ResultsPop_Image(PopUpManager.createPopUp(this,  
ResultsPop_Image, false, PopUpManagerChildList.POPUP));
   pop1.x=80;
   pop1.y=Application.application.height - 350;
   pop1.content = content;
   pop1.address = args[0];
   pop1.image = args[1];
   pop1.addEventListener(CloseEvent.CLOSE, pop1_close);
   }
   else
   {
     // refresh the data on the pop up
     pop1.content = content;
     pop1.address = args[0];
     pop1.image = args[1];
   }
  }

  // Close the pop up with identify results
  protected function pop1_close(event : CloseEvent) : void
  {
    pop1 = null;
    pop1.removeEventListener(CloseEvent.CLOSE, pop1_close);
  }

I have a function that closes all pop-ups that are open:

  // Call close event on all open popups so that effects run
  private function closePopups():void
  {
   var popupPackage:Array;
   var popup:iPopup;
   for (var i:Number=0; i<systemManager.popUpChildren.numChildren; i++)
   {
    popupPackage =
getQualifiedClassName(systemManager.popUpChildren.getChildAt(i)).split("\
::");
    if (popupPackage[0] == "components")
    {
     if (systemManager.popUpChildren.getChildAt(i) is iPopup)
     {
      popup = systemManager.popUpChildren.getChildAt(i) as iPopup;
     }
     else
     {
      popup = null;
     }
    }
    if (popup != null)
    {
     popup.dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
    }
   }
  }

I think that's all of it. I'm hoping someone can shed some light on
this.

Thanks!!

Reply via email to