1 Reply Latest reply on Mar 8, 2007 10:46 AM by Newsgroup_User

    Alert Component with OnKillFocus Causes Infinite Loop

    IDM New Media
      I have this script...

      txtPPM.onKillFocus = function(txtPPM)
      {
      import mx.controls.Alert;
      Alert.show("blah blah");
      };

      When my focus shifts away from the txtPPM textfield I get an infinite loop error. I haven't been able to find a successful method to fix this. Any suggetions?
        • 1. Re: Alert Component with OnKillFocus Causes Infinite Loop
          Level 7
          Probably related to the FocusManager (V2 components). There may be other
          ways to work around it, but here's something quick:


          import mx.controls.Alert;

          var alertClickHandler:Function = function (evt_obj:Object) {
          switch (evt_obj.detail) {
          case Alert.OK :
          trace("You clicked: " + Alert.okLabel);
          break;
          case Alert.CANCEL :
          trace("You clicked: " + Alert.cancelLabel);
          break;
          }
          txtPPM.onKillFocus = txtFocusHandler;
          };

          function showAlert(){
          Alert.show("blah blah blah", "", undefined, this, alertClickHandler);
          }
          function txtFocusHandler(newFocus:Object){
          this.onKillFocus = undefined;
          showAlert();
          }
          txtPPM.onKillFocus = txtFocusHandler;