« The Future of Brightcove and Aftermix | Main | Ask Steven Webster for Adobe At Your Doorstep »

Linking to External Source Folders in Flex Builder

One problem I've always had with Flex Builder is that I can't reuse projects which link to source folders outside of the main source folder. These external source folders are usually defined with an absolute file path, which makes the project files unusable by other developers without changes. And changes mean that project files don't stay in sync, which is just one more thing to worry about.

Usually, the external source folder is a folder for test files, but it can also be some folders that really should be in a SWC. In any case, the project file isn't sharable in the current form, and we all like to share.

I learned from some developers at Brightcove that there is a solution to this using a built-in Eclipse feature. First, you need to set up a linked resource:

1. In Flex Builder, go to "Window > Preferences".
2. Navigate to "General > Workspace > LinkedResources".
3. Within LinkedResource, create a new variable that links to the folder you want to include or some common base directory. Usually, you'd enter some base directory within source control that could be reused for more than one external source path.

Once you have the linked resource, you'll want to add a source path to your project. Right-click on the project, go into "Properties", "Flex Build Path", "Source Path". As normal, select "Add Folder", but don't browse to the directory. Instead, use the linked resource name, either by itself:

${LINKED_RESOURCE_NAME}

Or if it's a base directory, you can tack on directories:

${LINKED_RESOURCE_NAME}/my_source/location

OK it, and it's all set up. Then you can share the project file to other people on the team, or check it into source control. Each member of the team will need to define the linked resource, as shown in the steps above, but the project files don't have to change.

Comments (5)

Jeff Hindman:

This may be a dumb question, but how do you access the liked resources from within a Flex app?

Thanks --

Jake

The linked resources are only used within Flex Builder and just show where certain directories are located. These paths won't show up in a Flex app.

If you want to have a specific path compiled into your Flex application (or usually it's a specific URL that needs to be compiled in), I'd suggest doing token replacement via Ant before opening Flex Builder.

This is great! I've tried for ages to find a comfortable place to put my project graphical assets: in the root path makes for very long source strings, in the view path is too hidden and using modules (seperate projects) means the assets are sperated & management is a pain. Now I can have one single external source of all my assets. beautiful! Thanks :)

Scott Chu:

I already use this method in my project. However, I want to share a problem, which I can resolve it even now, here:

I add 2 source path resource in my project, say source path A & B as follows:

A has com/a/test/a1.as
in a1.as I define a class AAA (so the package name is com.a.test.AAA)
B has com/b/test/b1.as.
in b1.as I define a class BBB (so the package name is com.b.test.BBB)

When I use editor to type 'import com.b.test.BBB' a1.as, the editor will recognize com.b.test.BBB package name & auto-complete the rest package name for me (so I think the compiler should know it, too)

However, the compiler issues error 1072 which it can't recognize BBB class in a1.as

Scott Chu:

Sorry for typo in my last post. I mean I CAN'T resolve it even now. And the error should be 1172. On second check, it's very weird that I add a 3rd source path but it can refer to other package correctly. Only in a1.bas I can't refer to package BBB, there's always error 1172?