When I set the source property for a SWFLoader this string works fine:

  • source=”images/MyFile.swf”

…but this string gives me the above error:

  • source=”@Embed(source=’images/MyFile.swf’)”

Why?

I couldn’t easily Google an answer to this, so it may be worthwhile to post what I learned.

I found two causes for this problem. First of all, for some reason you need an additional slash when you use @Embed, like this:

  • source=”@Embed(source=’/images/MyFile.swf’)”

Second, the location of the SWF (or GIF, JPEG, PNG or SVG) may need to be different if you’re using @Embed, so that the compiler can find and embed the file at compile time. A copy of the file should be placed in a location relative to the source file that contains the SWFLoader.

Example: In my case I’m placing my SWFLoader in a custom component that is part of a code library. The code library lives in a separate location from the project that’s using the component.

For the non-embed example above I can place MyFile.swf at [MyProject'sMainSourceFolder]/images/MyFile.swf. FlexBuilder copies it to [MyProject'sOutputFolder]/images/MyFile.swf and the SWFLoader finds it there at run time.

But when I use @Embed, when the compiler sets about embedding the file it expects to find a copy at [MyLibrary'sOutputFolder]/images/MyFile.swf.

HTH :)

Update: Just found some info in on this in the docs, here:

http://livedocs.adobe.com/flex/2/docs/00000970.html#176435

14 Responses to “@Embed, Paths, and the “unable to resolve ‘[filePath]‘ for transcoding” Error”

  1. Michael Newman Says:

    Thanks so much for the tip. This problem was going to drive me up the wall. Thanks!!! I wonder why that extra / needs to be there. Also it might be worthwhile to note for programmers like me whose IT department are security crazy: you can’t link to fonts that you as a user can’t actually touch.

  2. Howard Says:

    I have the same problem, but which folder should the images be stored. I tried the bin the folder, but Flex is still not displaying the images. Any one, any help will be appreciated if you can help me solve this issue that I am having.

  3. Nils Says:

    Bless you! This was driving me crazy.

  4. Joe Says:

    I have the same problem as Howard. I can’t get the images to display. Any ideas?

  5. Bogdan Says:

    Hi all,

    I have this problem with the flex ant task.
    I’m trying to compile a project. I use @Embed(source=’../assets/first.png’) and the problem is that the compiler does not find it.

    PS. for displaying the images just use put the path relatively to the resource. As example I’ve created a war and I’ve put my swf files into the root and the rest in different paths.

    As struct: /(root of the war)
    /res/image.gif
    /test.swf // -> path to /res/image.gif
    /WEB-INF/web.xml // for war ;)

  6. Geoff Says:

    Was having the same problem!
    Your help solved it!!
    thnx man!

  7. Rob Says:

    Thanks for the tip – saved a lot of frustration!

  8. Jason Says:

    I have same problem, mainly the complier can not find out path of image,so I put image copy to file which import this image where in dir. In .as file
    Embed(source=’MyFile.png’) It’s OK.

  9. Bleh Says:

    Adobe needs to FIX this and make it function better. If you want to put your source in a “src” folder, this basically screws you. Assets should be placed in a special folder, ex. “assets”? Not wherever the files that need to access them happen to be, and not /src/assets. Dropping the assets into the same folder as the class referencing them is no answer either, what if two classes in different folders need to access the same asset? Lame…

  10. Aleksandr Says:

    Try using escape char “\” in path. Should work.

    [code][Embed(source="C:\\WINDOWS\\Fonts\\arial.TTF", fontFamily="DaEmbeddedFont", mimeType="application/x-font")][/code]

  11. Jobin Basani Says:

    Thanks!!! You saved my life :)
    Was trying to figure out what went wrong…

  12. Muad'Dib Says:

    This link saved me what could have been many hours of research and frustration!!! thanks!

  13. Thomas Kornechuk Says:

    Very helpful.

    Just an additional clarification. Your suggestion also applies when embedding an image like this example:

    [Embed(source="/images/filter.png")]
    [Bindable]
    public var filterOffImage:Class;

  14. Hristo Hristov Says:

    Thanks so much for this post. Was pulling my hair out and all I really needed was a slash.

    I was using an image like Thomas so just placing a slash in front fixed the problem.

    [Bindable]
    [Embed(source="/assets/stop.png")]
    private var Icon:Class;

    I also had to fix my fonts url in the stylesheet

    @font-face {
    src: url(assets/fonts/Helvetica.ttf);
    fontFamily: “Helvetica”;
    advancedAntiAliasing: true;
    }

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word