4 Replies Latest reply on Aug 21, 2006 2:46 AM by Ed_Syrett

    FlexBuilder not checking for errors in AS files

    rj.owen@effectiveui.com
      FlexBuilder 2 isn't finding any errors in AS files that aren't explicitly referenced in an MXML file for anyone in my office. This seems like a pretty basic function everyone needs, so I can't imagine it's not a huge bug....

      To be more specific, I have a flex project set up with two files in the root named SimpleTest.as and test.mxml. If test.mxml is empty, I can write absolutely anything into the .as file and flex builder won't locate any errors in real time. As soon as I instantiate an instance of SimpleTest in my mxml file, however, flex builder suddenly reports all of the problems in the problems view, and we're good to go.

      This is a huge pain from a development standpoint - I don't want to have to keep an instantiation of a class just to find if there are any errors in it. And if I'm not able to find errors in real/development time, FlexBuilder becomes a glorified text editor with the only real useful AS feature being code hints.

      If the project is an ActionScript project instead of a Flex project, flex builder will detect errors on AS files if they're in the root package, but files nested in folders aren't checked for errors unless an instance of the class exists in another root-package object.

      Is there anything we can do to fix this? Is anyone else seeing this error?

      Thanks.
        • 1. Re: FlexBuilder not checking for errors in AS files
          inlineblue Level 1
          Well, it makes sense to me that the IDE should ignore a file if you're not actually using it. Imagine all the classes that could potentially exist along the build path--compile times would be horrendous. If you don't plan to instantiate a class, then why're you writing it? Surely you need to test your class as you write it? That test app certainly needs to instantiate it.
          • 2. Re: FlexBuilder not checking for errors in AS files
            Level 7
            Plus one.

            The builder is quirky in that respect. The current design of the incremental
            compile is "interesting". But hey, the builder makes up for it when you use
            your component(s) in several root mxml files: then you get multiple copies
            of the same errors and warnings.

            --
            J�rgen Failenschmid


            • 3. Re: FlexBuilder not checking for errors in AS files
              Ed_Syrett Level 1
              Sorry guys, but the way Flex ignores unreferenced .as files is just plain wrong, and it's also inconsistent. There... thats the synopsis of this post, now the explanation.

              In our app, we want to have a list of menu items that are read in from the database. Each item consists of the man-readable text and the name of a class that is normally derived from TextWindow. The user clicks on a menuitem and the window appears.

              Flex provides the function flash.utils.getDefinitionByName() which will return the class definition for the given class name supplied as a string. But it will only work if the class is loaded i.e it has been referenced somewhere. To get around this, I have had to create my own map of class names to class definitions. In other words, I've had to rewrite getDefinitionByName.

              quote:

              Well, it makes sense to me that the IDE should ignore a file if you're not actually using it.


              Yes, but what the IDE doesn't know is that you may want to create an instance of the class without referencing it directly. getDefintionByName is the proof that there was/is some intention to be able to do that. IMO this is a reasonable thing to want to do, e.g if functionality is enabled/disabled according to user security, then one would expect to be able to dynamically create classes at runtime. getDefinitionByName() should allow me to do that. After all, the function exists to begin with, so it should work. But it only partially works because the IDE doesn't load up unreferenced .as code.

              If the .as file appears in the project, it should be compiled. Period. The fact that it is not referenced should not determine whether or not it is compiled. getDefinitionByName would then work as I reasonably expected it to work and allow dynamic creation of classes.

              The Inconsistency I mentioned earlier is therefore that Flex offers the getDefinitionByName but renders it pretty useless as you have to reference the class anyway.

              Finally all the other development languages I have used will compile all source in the project regardless of whether or not it is referenced. This includes C++, C#.NET and Visual Basic. So Flex is definitely the odd one out here.

              • 4. Re: FlexBuilder not checking for errors in AS files
                Ed_Syrett Level 1
                Sorry guys, but the way Flex ignores unreferenced .as files is just plain wrong, and it's also inconsistent. There... thats the synopsis of this post, now the explanation.

                In our app, we want to have a list of menu items that are read in from the database. Each item consists of the man-readable text and the name of a class that is normally derived from TextWindow. The user clicks on a menuitem and the window appears.

                Flex provides the function flash.utils.getDefinitionByName() which will return the class definition for the given class name supplied as a string. But it will only work if the class is loaded i.e it has been referenced somewhere. To get around this, I have had to create my own map of class names to class definitions. In other words, I've had to rewrite getDefinitionByName.

                quote:

                Well, it makes sense to me that the IDE should ignore a file if you're not actually using it.


                Yes, but what the IDE doesn't know is that you may want to create an instance of the class without referencing it directly. getDefintionByName is the proof that there was/is some intention to be able to do that. IMO this is a reasonable thing to want to do, e.g if functionality is enabled/disabled according to user security, then one would expect to be able to dynamically create classes at runtime. getDefinitionByName() should allow me to do that. After all, the function exists to begin with, so it should work. But it only partially works because the IDE doesn't load up unreferenced .as code.

                If the .as file appears in the project, it should be compiled. Period. The fact that it is not referenced should not determine whether or not it is compiled. getDefinitionByName would then work as I reasonably expected it to work and allow dynamic creation of classes.

                The Inconsistency I mentioned earlier is therefore that Flex offers the getDefinitionByName but renders it pretty useless as you have to reference the class anyway.

                Finally all the other development languages I have used will compile all source in the project regardless of whether or not it is referenced. This includes C++, C#.NET and Visual Basic. So Flex is definitely the odd one out here.