5 Replies Latest reply on Jul 10, 2006 12:07 PM by ekokurtz

    Comparison problem

    ekokurtz
      Has anyone had this happen to them after moving to the new version?:

      Error is '1067: Implicit coercion of a value of type Boolean to an unrelated type Number.'

      I've isolated the problem, and it must be a variable typing issue that is causing the problem, but I don't know why. Anyone have an idea?

      - problem in bold (I know the item reference should use brackets but didn't want it to show up here as italic)

      if (censusArray(i).birthyear != '') {
      if ( isNaN(censusArray(i).birthyear) == false & (censusArray(i).birthyear.length == 2)) { // check birthdays
      var tempBY:Number = tempBY + 1;
      }
      }

      This also gives the same error:

      if (censusInfo.enabled == false)
        • 1. Re: Comparison problem
          Level 7
          Do you have a complete program that you can post that shows this problem?

          As you surmise, the problem is a typing issue, but the snippet does not
          contain enough information to determine the issue. If it's not feasible
          to post a complete program, the key data needed are:

          1) The declaration of censusArray. What is its type, and what is the
          type of its elements?

          2) The declaration of censusInfo.

          -- Greg Dow
          -- Adobe Flex Builder Team

          ekokurtz wrote:
          > Has anyone had this happen to them after moving to the new version?:
          >
          > Error is '1067: Implicit coercion of a value of type Boolean to an unrelated
          > type Number.'
          >
          > I've isolated the problem, and it must be a variable typing issue that is
          > causing the problem, but I don't know why. Anyone have an idea?
          >
          > - problem in bold (I know the item reference should use brackets but didn't
          > want it to show up here as italic)
          >
          > if (censusArray(i).birthyear != '') {
          > if ( isNaN(censusArray(i).birthyear) == false &
          > (censusArray(i).birthyear.length == 2)) { // check birthdays
          > var tempBY:Number = tempBY + 1;
          > }
          > }
          >
          > This also gives the same error:
          >
          > if (censusInfo.enabled == false)
          >
          >
          • 2. Re: Comparison problem
            ekokurtz Level 1
            var censusArray = new Array({gRow: '',gender: '',birthday: '',birthyear: '',salary: '',salarycode: '',sclass: ''});
            [Bindable]
            var censusCollection:ArrayCollection = new ArrayCollection(censusArray);


            censusInfo is the ID of a form and gets disabled if information provided to censusArray is not correct

            for what it's worth, this line appears okay, which makes this more puzzling:

            if (isNaN(censusArray(i).sclass) == false) { // check classes
            • 3. Re: Comparison problem
              Level 7
              One quick thing I noticed is that censusArray does not have type, so it
              gets the default type of Object.

              Was this a typo? Is the declaration actually:

              var censusArray:Array = new Array( ... );

              -- Greg

              ekokurtz wrote:
              > var censusArray = new Array({gRow: '',gender: '',birthday: '',birthyear:
              > '',salary: '',salarycode: '',sclass: ''});
              > [Bindable]
              > var censusCollection:ArrayCollection = new ArrayCollection(censusArray);
              >
              >
              > censusInfo is the ID of a form and gets disabled if information provided to
              > censusArray is not correct
              >
              > for what it's worth, this line appears okay, which makes this more puzzling:
              >
              > if (isNaN(censusArray(i).sclass) == false) { // check classes
              >
              >
              • 4. Re: Comparison problem
                ekokurtz Level 1
                Changing that made no difference (and it worked the way it was in beta 3)...all lines that check for a false value and compare another value in the same statement have trouble , i.e.:

                if (censusInfo.enabled == false & censusMessage.length > 0) {
                Alert.show('The following group information needs corrected:\n\n'+censusMessage+'\n');
                }
                • 5. Re: Comparison problem
                  ekokurtz Level 1
                  solution much simpler than originally thought - problem was that the '&' in the comparison needed to be '&&'. Not sure why it used to work, but changing that fixed the error message

                  Ethan