Configure Flex 3 SDK classpath

The Adobe Flex 3 documentation describes Flex SDK Configuration, and more specifically how to configure the source path and library path for the mxmlc Flex Ant task used to compile Flash application files. I don’t have Flex Builder, but I do have Flash CS3, so I can compile SWF files within the Flash IDE. However, I wanted to be able to build open source ActionScript without the requirement of a commercial product to compile Flash files, especially since I jump between Mac OS X and Windows XP as I am learning more. (Agus Santoso has blogged about Flex 3 sdk command line development with example on Linux.)

I have the Flex 3 SDK installed at the root of my user directory in Mac OS X:

~/flex

The structure of my documents looks like this:

~/flex/classes
~/flex/data

If I try to compile an ActionScript file that imports classes that I have in the classes directory, I will receive the following error, indicating that the classes are not being found.

Error: A file found in a source-path 'AS3DModTutorial' must have the same name as the class definition inside the file 'AS3DmodTutorial'.

The configuration file for the mxmlc Flex Ant task is stored here:

~/flex/frameworks/flex-config.xml

To configure the classpath, uncomment the following text:

<flex-config>
   <compiler>
      ...
      <!-- List of path elements that form the roots of ActionScript class hierarchies. -->
      <!-- not set -->
      <!--
      <source-path>
         <path-element>string</path-element>
      </source-path>
      -->
      ...
   </compiler>
</flex-config>

Change the XML to:

      <source-path>
         <path-element>/Users/stephen/flex/classes</path-element>
      </source-path>
Advertisements

About this entry