7 Replies Latest reply on Jun 9, 2008 3:55 AM by jorgecanta47

    combobox 256 levels of recursion

    jorgecanta47
      Hello there
      I am testing a really simple code and it turns out that when I change the value of the combobox I have, it is throwing this error:
      "256 levels of recursion were exceeded in one action list.
      This is probably an infinite loop.
      Further execution of actions has been disabled in this movie.
      "
      The code is this:
      "import mx.controls.Alert;
      activate=new Object();
      activate.change=function(evento){
      Alert.show("El selected value is: " + evento.target.value,"Message");
      };
      myCombo.addEventListener("change",activate); "
      One thing I know is that the error does not appear when I remove the sentence which shows the message, that is to say:"Alert.show("El selected value is: " + evento.target.value,"Message");"

      Does anyone has any idea about why I am getting this error?
      Thanks
        • 1. Re: combobox 256 levels of recursion
          kglad Adobe Community Professional & MVP
          bad component behavior.
          • 2. Re: combobox 256 levels of recursion
            jorgecanta47 Level 1
            What do you mean with "bad component behaviour"? Are you suggestion this is a bug which is not my fault?
            Thanks
            • 3. Re: combobox 256 levels of recursion
              kglad Adobe Community Professional & MVP
              yes, it's a problem with the components. there are frequent problems with components. especially, when more than 1 is used.
              • 4. Re: combobox 256 levels of recursion
                jorgecanta47 Level 1
                quote:

                Originally posted by: kglad
                yes, it's a problem with the components. there are frequent problems with components. especially, when more than 1 is used.

                Hello thanks for your help kglad. Anyways, this kind of problem sounds to me pretty strange. I mean, I thought adobe tested their products before launching them into the market. It is hard to believe that this can happen. One more question: since I am using just one component for this example with the combobox, do you think this still should happen? What solution do you suggest to work around this kind of problems?
                The last question: am I going to find many similar bugs to this one I just found?
                Thanks
                • 5. Re: combobox 256 levels of recursion
                  kglad Adobe Community Professional & MVP
                  i'm not sure all these components were made by adobe.

                  you're using two components: the combobox and the alert window.

                  and i suggest making your own movieclip to imitate the behavior of the combobox or alert windwo.
                  • 6. Re: combobox 256 levels of recursion
                    Level 7
                    As kglad explained, the problem is related to bad (or at least unexpected)
                    component behavior.

                    But you can work around the problem by delaying the Alert until the ComboBox
                    has closed its dropdown. Something like this:


                    import mx.controls.Alert;
                    var activate:Object = new Object();

                    var savedChangeEvent:Object = null;
                    activate.change=function(evento){
                    savedChangeEvent=eventto;

                    };

                    activate.close=function(evento){
                    if (savedChangeEvent != null){
                    Alert.show("El selected value is: " +
                    savedChangeEvent.target.value,"Message");
                    savedChangeEvent =null;
                    }
                    };

                    myCombo.addEventListener("change",activate);
                    myCombo.addEventListener("close",activate);


                    • 7. Re: combobox 256 levels of recursion
                      jorgecanta47 Level 1
                      Thanks a lot Raymond Basque. Your suggestion works fine. However, I have even tried to simplify your suggestion and this code works fine as well:

                      import mx.controls.Alert;
                      var activate:Object = new Object();
                      activate.close=function(evento){
                      Alert.show("The selected value is: " +
                      evento.target.value,"Message");
                      };
                      attachMovie("ComboBox","myCombo",1);
                      myCombo.addItem({data:1, editable:"true", label:"First Item"});
                      myCombo.addItem({data:2, label:"Second Item"});
                      myCombo.addEventListener("close",activate);

                      I guess, the problem had to do with calling the function Alert.show inside the onchange event which for some reason is not compatible with the call Alert.show.
                      Solved for the time being.
                      Thanks