Using Eclipse for Flex 1.5 Development

So you want to use Eclipse to do Flex 1.5 development? No fluff, I”ll get right to it.

What you are going to do is use the Flex 2 alpha and point it to the Flex 1.5 compiler. This will compile your application into a SWF, which will be put in your web site.

  • Start with getting the Flex 2 alpha plug-in (either stand alone or plug-in). Follow the installation instructions, if necessary, to get Flex Builder 2 running. Once it is working, create a new Flex Project using the menu bar: File > New > Flex Project
  • Now for the changes. Right-click the project that will use the Flex 1.5 compiler and select Properties. This will open the Properties dialog. In the list on of properties on the left hand side, select Builders. You are going to add a new builder and disable the existing one. When you deselect the existing ”Flex Builder” builder you will get a prompt. Just click OK.
  • Click the New button to create a new builder. The configuration chooser dialog will open. Select Program and click OK.
  • Now you are ready to set the new builder up. Give it a name like ”Flex 1.5”.
  • Set the Location to point to the mxmlc.exe file, most likely something like this: C:\Program Files\Macromedia\Flex\bin\mxmlc.exe
  • Set the Working Directory to point to the directory holding the compiler. Something like this: C:\Program Files\Macromedia\Flex\bin\
  • And now the hard part… the arguments. Click the variables button and select the project_loc variable. This is an eclispe variable which has the absolute file system path for the project. Double-click project_loc to select that variable and close the dialog. Now append to the end of the variable the path to the main application mxml for the project. Something like this: ${project_loc}\Main.mxml
  • You need to add two more arguments; one that points to the flex-config.xml, and an output file. To do so, you will add the -configuration switch and the -o output file switch. They will look something like this: -configuration ${project_loc}\WEB-INF\flex\flex-config.xml -o C:\inetpub\wwwroot\mysite\Main.swf

In the end the arguments will look something like this: ${project_loc}\Main.mxml  -configuration ${project_loc}\WEB-INF\flex\flex-config.xml -o C:\inetpub\wwwroot\mysite\Main.swf

  • One last thing I would do is run your application the old way and copy the source HTML from a dynamically created Flex site (i.e. view source from the browser). Then create a new HTML page with the HTML source you copied. Finally, change the references to the [filename].mxml.swf to your new SWF ([filename].swf)

That”s it!

Thanks again to Marcin, Sean and Tony for sharing with me.