12-15-2010 12:25 PM - edited 12-15-2010 12:33 PM
I want to view an image form the applicationStorageDirectory but I get an URL not found error.
var imgLoad:Image = new Image();
The image test.png is present in that directory but I can't load it.
Does anyone have a solution?
Solved! Go to Solution.
12-15-2010 12:35 PM
How did you get that image in the storage directory? Installed files are only in the applicationDirectory relative to the /src of your project. If that image was saved there and the File "exists" method is returning true, it might be related to something else.
12-15-2010 12:44 PM
If the file does exist, you can use try this solution using QNX's Image Class ( thanks JRab )
12-15-2010 12:49 PM
jrab's example is for files relative to the project /src directory. They're trying to load a file from the application storage directory. I do this in one of my apps and it works fine as an AIR application, but I think there might be a problem on the PB. I wll double check.
12-15-2010 12:52 PM
Yes, I too am having trouble loading an image from the app storage directory. I dont have trouble access preference files from the same directory. This might require a work around by loading the image into memory as a bitmap and then setting that to the image.
12-15-2010 12:56 PM - edited 12-15-2010 12:58 PM
Thank you for the quick reactions
The image is created by the application and I checked Its existence.
The "Image" class in the piece of code is already the qnx.ui.display.Image class.
12-15-2010 01:20 PM
"The "Image" class in the piece of code is already the qnx.ui.display.Image class."
Yes it was... :blush: I didn't notice the setImage(... portion of your code.
12-15-2010 02:14 PM - edited 12-15-2010 02:29 PM
this was bugging me too but then saw the documentation closer and an assist from harry_dodgson. in the setImage method it requires a URL input not just an absolute path. so do this:
nativePath + "/test.png");
imgLoad.setImage("file://" + File.applicationStorageDirectory.nativePath + "/test.png");
and you should be golden. hope that helps! good luck!
Edit: from the documentation:
"... The image parameter can be of type String as a URL to an external image..."