The paths inside [Embed] metadata tags seem to be handled differently depending on if it's a pure Actionscript project or a Flex project.
In a Flex project, I can create a tag like this:
[ Embed(source="myAsset.png") ]
And the compiler will search for the file myAsset.png at the root of the project
In an actionscript project however (AIR or SWF) I get the following compiler error:
|Could not find Embed source 'myAsset.png'. Searched '/Users/doug/Documents/Adobe Flash Builder 4.7/asWebTest4.7/src/myAsset.png', 'embeds/myAsset.png' in SWCs on the library path||Main.as||/asWebTest4.7/src||line 8||Flex Problem|
In order to get Flash Builder to find the file, I must either supply an absolute path, or a path relative to the file containing the [Embed] tag.
This disconnect between Flex projects and Actionscript projects is problematic from a user experience perspective, and likely to cause confusion. Also, this causes projects built in previous versions of Flash Builder to no longer compile. The actionscript compiler should interpret Embed paths as relative to the project folder, IMO.
As a side note, the phrase "in SWCs on the library path" in the compiler error is confusing in my opinion as it seems to imply that the compiler is searching filepaths inside of SWCs somehow. Perhaps it should say, "Searched '/Users/doug/Documents/Adobe Flash Builder 4.7/asWebTest4.7/src/myAsset.png', 'embeds/myAsset.png', and in SWCs on the library path" ?
There is a change in new compiler on how it resolves [Embed] metadata paths. (refer http://bugs.adobe.com/jira/browse/FBG-4671 )
The reason this behavior is different from Flex projects is they still use legacy compiler.
unfortunately I don't have the necessary permissions to view that jira ticket.
The path resolution in the new compiler has some drawbacks.
1. Having to add a bunch of "../../../" to the source path makes for less readable code.
2. Under the new scheme, any time you move a file, and potentially when you rename a package, you must update all the [Embed] metadata contained within.
3. Legacy projects will break in the new compiler. It will not be possible to work on the same project in both FB 4.6 and FB 4.7
Im not sure exactly what's going on under the hood, but it would sure be nice if Flash Builder could feed the compiler the project root as one of the locations to try resolving the path.
[Edit] Or, if we had the option in 4.7 to specify which AIR SDK we wanted to use on a per-project basis
You can refer to embedded assets either relative to the embedding file (though this is less portable, as you note) or relative to a rooted location (Mac/Unix OS root, source root(s), library-path SWC roots) using a leading forward slash (this is similar to how paths are used in HTML to refer to items from the webroot):
The forward slash approach should work in 4.6 and 4.7.
The special "Eclipse path" resolution is no longer supported in sourc ecode embedded paths in 4.7 (since those are not portable to command-line or ant builds).