Displaying images in AIR app
I want to display an image located in the app-storage directory of my AIR application. This image has to be displayed in an html text area where the html text is coming in from a local embed开发者_Go百科ded sqlite database.
When I put in the following code:
imageTest.htmlText = '<img src="app-storage:/demo.jpg" border="0" />';
nothing is displayed.
But when instead of the app-storage path, I put in the absolute url of an image on the web, like below:
imageTest.htmlText = '<img src="http://www.example.com/demo.jpg" border="0" />';
the image is displayed correctly.
Also, I checked that the app-storage method is able to locate the image, but it just does not display in an htmlText container. For example, the following code displays the image:
imageTest.location = 'app-storage:/demo.jpg';
Any suggestions what I should do to get the image to display? I am using Adobe Flex Builder 3 as the IDE.
Thanks
VinayakSince your loading the html as a string it isn't in the application sandbox by default. Have you tried setting:
placeLoadStringContentInApplicationSandbox = true;
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/html/HTMLLoader.html#placeLoadStringContentInApplicationSandbox
Have you tried this?
imageTest.htmlText = '<img src="'+ File.applicationStorageDirectory.nativePath +'/demo.jpg" border="0" />';
This is very strange! The following code works for displaying images when I use the open source Flex Builder SDK on the Eclipse IDE, but does not work when I use the Adobe FlexBuilder IDE:
imageTest.htmlText = '<img src="app-storage:/folder/demo.jpg" />';
Maybe it is a bug.
Have posted as a bug:
https://bugs.adobe.com/jira/browse/FB-25986
精彩评论