3 Replies Latest reply on Apr 2, 2008 5:21 AM by riesvantwisk

    missleading warning message

    levancho Level 3
      I have :
      var somefunc:Function =giveMeMyFunc();
      if(!somefunc) ...
      I get very misleading warning :
      "Function value used where type Object was expected. Possibly the parentheses () are missing after this Function refference"

      but if I do this :
      if(somefunc==null) no warming shows up,

      this sounds like a bug?

      is this a bug?
        • 1. Re: missleading warning message
          riesvantwisk Level 1
          Hey,

          do you happen to come from a PHP world???

          If so, then if (!var) is possible in PHP, but not in ActionScript.

          ActionScript is strong(er) typed then PHP so you have to compare a variable against something. In PHP variable can change type.. in ActionScript not.

          So if (!variable) means nothing in Actionscript.
          For example if var==null, what is !var ??

          Ries
          • 2. missleading warning message
            levancho Level 3
            I dont agree,
            in AS if (!var) means same as if (var==null) , remember AS is based on EcmaScript and last I checked EcmaScript still allows this kind of notation.

            its actualy very easy to test :

            var test:Object = null;
            Alert.show(!test+""); // output true
            Alert.show((test==null)+"");// output true

            test = new Object();

            Alert.show(!test+""); // output false
            Alert.show((test==null)+""); // output false

            P.S I come from java :) world .
            • 3. Re: missleading warning message
              riesvantwisk Level 1
              Hey,

              properly you are right. I have had the same, but now trying I couldn't duplicate it.

              Me coming and doing a lot with database I find the while if (!Object) very strange where a object can be null.

              SELECT NULL; -- results in NULL
              SELECT NOT NULL; -- result in null

              Both of the below statements return true :)
              select NULL IS NULL;
              select (NOT NULL) IS NULL;

              Anyways, I started to get used to specifying what I really mean eg:
              I am nowdays using if (object == null)

              I think in the above message that AS might get confused because it finds a function with the same name, might be a bug indeed....

              Ries