1 person found this helpful
Unless you embed the asset, I don't think you can refer to the image in a library project with a URL.
Try moving the image to the project from which you are building the AIR file (I'm assuming you are using AIR because of the app:// reference) and make sure it is checked in the third step of export release build. Then your app:// reference should work.
Also, if you choose to embed it rather than move it, a binary representation of the image becomes part of the SWF. So the reference to the image is only via that class object. In your library project, define an ActionScript class which has a public variable (your myImageClass). You can refer to this public variable from your referenced project. Also, try using:
var myImg:BitmapAsset = new MyImageClass() as BitmapAsset;
instead of the equivalent line in your sample.
(See http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html for a full sample)
Your embed example works, but there I have a BitmapAsset. How can I get the url to this image? Is that possible?
If not, then I only need an external file for the desktop version of my application, because your idea with moving the file to the application project worked. If I move them into the "main" project, I can reference them using app:///files/myimage.png.
Thanks a lot.
If the asset is embedded, then there's no URL for that image. The variable under the Embed directive is your only reference to the image.
What do you want to do with that image? If the requirement is to display it, you can set the variable you create as a source to mx:Image. If you want to manipulate it, you can access the BitmapData from the BitmapAsset and then use mx:Image to show it.
I actually need the url to this image in order to pass it on. Since the code I pass it to is not my own, I can't change the return value to "image".
If it is not possible to get the url of an embedded image, I just have to stick to the app:// url for the mobile version and an external file for the desktop version.