11 Replies Latest reply on Jan 16, 2009 8:29 AM by GerryIsHere

    Array length

    GerryIsHere Level 1
      Hi there !

      How do I proceed to warn a user that the number of Items he/she attempts to load in a Combo Box is too large?
      I used the code below but it doesn't work...
      What's wrong?
        • 1. Re: Array length
          clbeech Level 3
          three items here Gerry: in the conditional use the 'length' property - rather than 'index' (which is not a property of the array class ;), additionally the 'break' in the first part of the condition will only effect a loop, and there is not one present at this point so you can remove it.

          also in the loop, the condition is not necessary, the loop will terminate on it's own upon reaching the final index of the array.
          • 2. Re: Array length
            GerryIsHere Level 1
            Thanks for responding!

            Here is the code I used following your indications.
            But it doesn't work.

            Even labels_array greater than 200 items don't trigger the first conditional...
            When I write labels_array.length, I suppose length refers to the number of items in the array. Right ?
            length never refers in this case to the number of characters. Right ?

            I don't understand why "Too large number of friends to display." doesn't appear when an array larger than 200 items is loaded.
            There must be something wrong somewhere...


            • 3. Re: Array length
              clbeech Level 3
              right 'length' refers to the number of elements in the array and 'not' the number of characters.

              let me ask quick - if the list is 'less than 200' does the CB propagate correctly?
              • 4. Re: Array length
                GerryIsHere Level 1
                Oh yeah !!!
                It displays fine and speedy.
                • 5. Re: Array length
                  clbeech Level 3
                  ok - great! so I thinking try removing the data parameter in the addItem method call under the condition - although this shouldn't matter, and it 'should' accept an empty string. also throw a quick trace in there to see if the condition is being met:

                  trace('condition triggered');
                  • 6. Re: Array length
                    clbeech Level 3
                    I'm also wondering if the 'label' param string has a character limit - maybe try it with something smaller.
                    • 7. Re: Array length
                      GerryIsHere Level 1
                      trace statement doesn't display the expected information
                      and, no, thre's no character limit to this string...

                      I definitely think that the conditional is somehow wrong or misplaced (?)...
                      • 8. Re: Array length
                        clbeech Level 3
                        ok - with the 'list' containing more than 200 - place a trace just before the condition


                        what do we get?
                        • 9. Array length
                          GerryIsHere Level 1
                          I GOT IT !!!
                          What do you think ?
                          Look at the code below...
                          • 10. Re: Array length
                            clbeech Level 3
                            well... ... ... sorry buddy - but that's not going to help you - it will only 'check' the condition 'once' at the start of the program, and 'not' after the load has completed - thus if you have more than 200 the CB will still ... ... wait a sec how is 'myFriendsList' working outside the load handler???? isn't that the item being loaded????
                            • 11. Array length
                              GerryIsHere Level 1
                              This chunk of code is part of a "big" function which is called each time the user search for a friend from a given school in a given year.

                              After finding (or not) this friend, the Combo Box "CBFRIENDS" displays all the friends of this found friend who were in the same school the very same year.

                              Then, the user choose in this CB a friend which is searched by the "big" function and so on...

                              I have tested this under all conditions and it perfectly works.

                              PS: Have also a look to another post I did this morning related to ComboBox Items Limit...