Source path in [Embed..] problems
I'm trying to embed an image but have problems with the source path.
I have an image next to my compiled swf and I try this:
[Embed(source="image.png")]
But I get compiler errors that it can't find the file. I've read somewhere that the relative root can be something else than the actual output folder but I nothing I've tried have worked.
However, if I use an abolute path like this:
[Embed(source="C:/folder/folder/folder/folder/bin/image.png")]
it works, meaning I can compile and the image shows, but IntelliJ still marks half of the path as erroneous.
So two different problems I guess.
请先登录再写评论。
SWF location doesn't matter. You compile source files and assets are usually kept within your source roots as well. Take a look at the spec, how assets can be referenced. I suppose in your case it is enough to add leading slash: [Embed(source="/image.png")]. Yes, absolute paths are also allowed, though it is not a good code style, and definitely you never should reference asset located in output folder.
Thanks!
Yeah I know the output folder is bad place, I just tried doing a quick test (usually have assets in swc:s), and I wanted to understand what was going on.
How do I set the source path as per example in the link you gave (-source-path=a1,a2,a3) in IntelliJ?
Content roots and source folders are configured in the Project Structure dialog, Modules page.