Cure For The ‘Unable to resolve asset for transcoding’ Compiler Error
Have you ever tried to embed an asset and ended up having mxmlc throw this error at you?
-
Error: Unable to resolve 'yourAsset' for transcoding
I ran into this for the first time this evening. I was working on a Flex application and needed to embed a PNG file in one of my classes like so:
-
[Embed(source="../assets/images/myImage.png")]
-
protected var myImage:Class;
No errors detected in the code, so I went ahead and did a debug build via Flex Builder and everything was just fine and dandy. Later on when I went to do a production build via my Ant build file, mxmlc threw that error. I quickly looked over my build file and everything looked fine, so I did a quick search online and didn't find any good solutions to this. Some others had posted about having this issue and resorted to adding their asset directory as a source directory. I wasn't down to do that, so I began experimenting. I finally managed to get it working; here is what did the trick:
-
[Embed(source="/../assets/images/myImage.png")]
-
protected var myImage:Class;
Yep... Simply adding a slash in front of the '..' made all the difference in the world. Pretty incredible. I just thought I'd vent and share that since I know I'm not the only person out there that has been caught up on this.
51 comments51 Comments so far
Leave a reply

I feel your pain.
I came across that same thing this summer when I was working on a project. Actually I have a question about embedding SWF files. I have been using Illustrator CS3 to do most of my design work and converting all of the elements into 'symbols' and exporting it as a SWF . Do you know how I might be able to access those symbols without embedding every single one, ie; [Embed(source='myMovie.swf', symbol='mySymbol')]. I am pretty new to AS but I am pretty sure there is a way I can do this. Thanks.
Hey Derek,
Once you have done something like this:
[Embed(source='myMovie.swf')]
protected var MyMovie:Class;
Create an instance of the 'MyMovie' class and listen for it's 'Event.INIT' event. Upon your handler for the 'Event.INIT' event being invoked, the assets inside of the 'myMovie' SWF file are now available for use like so:
var box:MyFlashBox = new MyFlashBox();
addChild(box);
Where 'MyFlashBox' is the class that is associated with the library symbol.
Just make sure that the 'Automatically declare stage instances' checkbox is unchecked in your ActionScript 3.0 Settings.
Thanks for the reply. This works great because I hate using the Flash IDE for design since I have been such a long user of Illustrator and now that it is more integrated with Flash/Flex makes it that much more intuitive for me.
Thanks again.
Merry Christmas and Happy New Year!
Cheers.
thanks for posting that man! You're a life saver
--some random guy
Hey just curious, does "./../myAsset.png" work, that should keep the asset relative to the mxml, and and has been the solution to custom class paths in the flash IDE for my office. Great articles BTW.
Thanks, Collin.
Correct, that path would check for the asset relative to the location of the class/mxml file rather than the directory the SWF is published to, just like '../myAsset.png' would. The compiler only begins looking for the asset in the SWF file's directory if the first character of the path is '/'.
thanks,
helped
guille
I have been tearing my hair out over this...
I've tried placing the image in the same directory as the main mxml file, in a directory containing a component. In a distinct "images" directory in the src, in the component and the "root" directory of the project, even copied and pasted examples from Adobe's own manual.
All failed.
And a frustrated hour later, your solution works perfectly
I'll let you guess at the choice words vented against Adobe, Actionscript and flex builder
Cheers,
Daniel
Just wanted to thank you (and Google) for the solution.
Hey, this was ultra baller. this saved me a ton of trouble.
Thanks!
Thank you !
+1
Another thank you!
Omg, crazy error!
Thanks.
+1
Well done tracking that one down - I was working up to a long session of brain-wracking. Must be something to do with concatenating paths, or similar. Clearly, FB does not use mxmlc internally in the same way.
Thanks a lot for sharing this!
Such a simple fix for such an annoying bug...
Hi ,
I am running into the exact issue, except that this time I'm trying to compile a Flex library out of my project using ANT. I am also using the compc executable to create this library.
The Flex project compiles without any errors in FlexBuilder(version 3.0) , however when I try to automate the build using ANT I get this error :
Error: Unable to transcode images/icons/vertical_bar_chart_16x16.gif
Here's how m directory looks like:
ProjectFolder
|
|----build -> Build file located here
|
|
|----com -> location of my source files
|
|----images -> location of image artifacts
I have a package called resources
package com.sap.xapps.analytics.resources
{
[Bindable]
public class Images
{
[Embed(source="images/icons/line_chart_16x16.gif")] public static const iconLineChart : Class;
}
}
Here's what my ANT compilation target looks like:
Building ${swcFile}
I get the above mentioned error when I run the ANT script from the build directory.
I have already tried using (/../images) and even (images/) in the .as file but it hasn't helped. Appreciate if you can suggest any alternatives.
damned... it was that easy !
Cheers for posting this
Thanks, this helped!
This is what I call a very useful post!
Thanks for sharing!
Thanks !!!!! that saved me a lot of pain.
Hi,
this really saved my day. I spent 2 hours on this annoying bug and the leading slash made it.
Thank you
Thanks! Very useful post!
wow. I've never had this happen before. thanks ryan!
Thanks! Saved me a ton of time.
Thanks! Saved me an headache
Thankyou very much for the solution
Fantastic! Thanks for posting this. I probably would've been playing around with this for hours otherwise.
Thank you!!!!
I had the same problem with embeded fonts. Now it´s fixed.
i have replace the paths with /../
but still its not working, when i change "../" to "/../" my flex builder shows errors and by command amxmlx is not working
Simple fix saved me hours. Thanks for sharing.
mad props! this was a huge help!
Thanks! It helped me!
Thanks! Ant building happily again
Thank you
This works really great... i was facing this issue from past 2 days but was not getting any proper answer.. this is just perfect... thanks a lot....
3+ years after you posted your solution, and it is still useful. Saved me a lot of frustration.
THANK YOU!
This worked. Thanks for the advice.
Thanks, simple fix
Simple fix saved me hours. Thanks for sharing.
Thanks for posting this!!! I ran into the same problem. This posting saved me lots of trouble.
You rock! I never had this error before, not sure why I got it today (might be the system I'm on). Thanks!
This was a great fix when using the Embed Tag but I am having the same issue if I try to embed in MXML like so.
adding the forward slash did not help in this case. Not sure what the fix is, any thoughts?
Last post didn't let me put mxml in the post. Here is a screen of what I am trying to do and I am getting error saying resource is not available in the compiler http://grab.by/aoBO
Hello.
Thank you so much for posting this solution!
You are the best!
Thanks
thanks a lot...
More than 4 years later and this is still an issue with FDT. Anyway, thanks for the hint, only after adding /../ to the assets path I managed to compile this project (was created on FlashBuilder) after banging my head for a while... XD
Cheers!
Like Ernesto said, it's amazing this is still an issue after so many years. Still, thanks for saving me a few hours of mind-numbing debugging!
You ROCK! Saved me hours of mucking with the build system. Thx.
Thanks! Saved me a crap load of debugging time.