7 Replies Latest reply on Aug 23, 2007 6:41 AM by levancho

    No Compile Time Checking for .as files?

      When developing code in MXML files (in a script tag) I get full syntax error warnings, invalid variable reference warnings etc. But whenever I have code in an .as file, I don't get *any* of that when editing the file in Flex Builder 2.

      Not only do I not get any warnings while coding, but any errors with the .as file ( including syntax errors), do not even get reported at compile time. I can type anything into an .as file and flex will compile and run the application without so much as a peep.

      This is obviously a serious problem. Is this the same for everyone else?
        • 1. Re: No Compile Time Checking for .as files?
          *.as files (and mxml files for that matter) are only checked if they are used. I.e. if you write a class but don't have any variables of that type, the file is never checked as it isn't compiled. Flex Builder only compiles classes that are needed for the application you are writing. So if you want the checking to work, make sure you've declared a variable of the class somewhere up the hierarchy.

          This is the same reason why errors are not reported in the files until those files are saved, as a compile doesn't happen unless something is changed.
          • 2. Re: No Compile Time Checking for .as files?
            Chekote Level 1
            I am using the classes in my project, they are simply not being checked at compile time. If I use exactly the same files in a project in the Flash IDE, I get compile time errors as expected.

            In regards to your second statement. I think you misunderstood what I meant. The Flex IDE gives real-time feedback on syntax errors etc when you are writing actionscript inside a script tag in mxml. It does *not* give any real-time feedback on syntax errors etc when you write actionscript in a *.as file.

            The errors are not reported regardless of if changes to the file have been saved or not.
            • 3. Re: No Compile Time Checking for .as files?
              Peter Flynn (Adobe) Adobe Employee
              Hi Chekote,

              If your AS class is not used anywhere in the application, it will get completely ignored by the compiler. Once a class is referenced in any way from your MXML code, it will get compiled and any errors or warnings will then be reported.

              - Peter
              • 4. Re: No Compile Time Checking for .as files?
                Peter Flynn (Adobe) Adobe Employee
                Oops, sorry -- hadn't seen the other reply. Does this problem still occur after you do a clean (Project -> Clean)? If you have a project that consistently reproduces this problem, and is not too big, please file a bug and attach your project to the bug. You can do this at http://bugs.adobe.com/flex

                As far as I am aware, Flex Builder doesn't give error feedback on AS code anywhere (AS file or MXML file) until you save your changes to the file.

                - Peter
                • 5. No Compile Time Checking for .as files?
                  Chekote Level 1
                  It seems that jmryan was correct. I wasn't aware that when he said the classes had to be used, that he meant used in an mxml file, which they weren't. My classes were just referencing each other.

                  So if I am writing a large *.as framework for use in a Flex project, and I haven't referenced any of the classes in an mxml file yet, I'm not going to get any errors reported while I am working on the *.as files?

                  Surely Flex should check the validity of *.as files in a project, regardless of if they are used by an mxml file. By being in the project they are obviously of enough significance that the developer requires feedback on errors.

                  I could be creating a 100% *.as based API. It seems counter intuitive that I need to use an mxml file just to enable validation. I would obviously need an mxml file eventualy to test the API, but to *require* one just for validation really seems bizarre.
                  • 6. Re: No Compile Time Checking for .as files?
                    Chekote Level 1
                    Well after a little more research, and as many people may already know, Flex Builder has an "Actionscript Project" that checks all *.as files in the project. So if I'm writing an *.as only API, then I should obviously use that instead.

                    I still believe all *.as files in a project should be checked regardless of their usage (or lack of).

                    Thanks for all the help guys.
                    • 7. Re: No Compile Time Checking for .as files?
                      levancho Level 3
                      FYI. Same thing applies to Custom MXML files, if they are not used you can put anything you want in there and IDE will not give a error .