2 Replies Latest reply on Jul 31, 2006 12:22 PM by cheftimo

    .mxml file name makes app fail

    cheftimo Level 2
      I have been using Aral Balkan’s Flex Quick Starts as an aid in Learning Flex, and first, I would like to opine that this man’s tutorials are the best I have seen in my entire involvement with Flex – not one word is wasted in these lessons (I don’t even recall seeing the word “rich” anywhere) and they are put together in a way that makes you think and figure things out on your own, just searching through the Flex Help – highly recommended for us newbies!

      Now, here is a weirdo, if I ever saw one:

      To study the lesson titled “Defining state transitions”, in FB2 I created an application file named “transitions.mxml”, into which I wrote the code. When I got through, the Problems window kept showing this message:

      “Type was not found or was not a compile-time constant: transitions. [Generated code (use –keep to save): Path: transitions-generated.as, Line: 265, Column: 14]” - (looks like Greek to me).

      Double-clicking on this line of the Problems window resulted in selection of the <mx:Application> tag in the code window, sometimes the opening, sometimes the closing tag, with no reference to a line number.

      I searched my whole computer for a filename “transitions-generated*”, with zero results. I did find a few files with “transition” in the name and found some (all .as files) in Flash MX and Flash 8 folders and only one anywhere near Flex – Transition.as in C:Program Files\Adobe\Flex Builder 2\Flex SDK 2\frameworks\source\mx\states.

      After looking at the code with a microscope a couple of times and finding no errors and beginning to think Aral had missed something, I renamed the mxml file and voilá, the error was gone and everything worked fine. I have tried renaming the file (two or three times) back to “transitions.mxml” and the error appears again. With the new name, everything still works perfectly.

      I have read about reserved words, but never in connection with file names. Is this something we have to be concerned with? If so, I would love to be pointed to some place where one can research it. Or, is this a bug?

      I might mention that I ran into the same exact problem with a CFC I created in Dreamweaver 8 a couple of months ago, where renaming the CFC fixed all the problems; I don’t remember the particulars, except that the name was NOT “transition’ or anything like it.

      Any light on this subject would be greatly appreciated.

        • 1. Re: .mxml file name makes app fail
          ntsiii Level 3
          Mxml files get generated into .as classes, with the name of the class being the name of the mxml file. So it is possible to get name collisions.

          I just had this happen wijth an example I posted. There was a function called "flashButton", and the person trying the example named the file "flashButton". The error complained about the constructor, which at first didn't make sense to me, but once I remembered the as class would hae the same name as the function and that the compiler would now see that function as a constructor, it became clear.

          I guess you either have to be watching, or use a naming prefix that will make name collisions very unlikely.

          • 2. Re: .mxml file name makes app fail
            cheftimo Level 2
            Thanks, Tracy. I suspected something like this, but being new at it, I wanted some verification. I'm just surprised not to find anything on the subject anywhere in the documentation.