Posts Tagged @embed

Dealing with @Embed Tags, Ant Builds, and Paths to Resources

There’s plenty of evidence on the blogs, Adobe bugs, and elsewhere, that there are issues dealing with the compiler locating resources at compile time.

You ask yourself, where do I put my assets, my images, my CSS files?

Using one notation, Flex Builder will find the resources but switching to Ant causes all hell to break loose.

Here’s a simple and fairly elegant way to deal with it.

There are two things you need to know to understand what’s going on.

  1. The forward slash(/) operator is used to indicate the root. But what is root? The Flex compiler considers the ‘main source folder’ to be the root. Hence when you say ‘/’, you are actually referring to the ‘Main source folder’ (which you can set in Project>Properties>Flex Build Path>Main source folder), which in most cases would be set as the ’src’ folder.
  2. How to traverse a path. Pretty simple. If you do something like [Embed(source="/../assets/images/icon.jpg")] and src is your main source folder, the compiler will start at src, go up one level, find the assets folder and voila!

Post to Twitter Tweet This Post

, , , , , ,

No Comments