Skip to main content
Inspiring
February 14, 2012
Answered

Cannot load image from applicationStorageDirectory

  • February 14, 2012
  • 2 replies
  • 2005 views

Hi!

At program startup I load binary data of images from a remote server and save them locally in my applicationStorageDirectory:

imageFile = new File(File.applicationStorageDirectory.nativePath);

imageFile = imageFile.resolvePath("images/" + obj.id + extension);

var filestream:FileStream = new FileStream();

filestream.open(imageFile, FileMode.WRITE);

filestream.writeBytes(loader.data);

filestream.close();

later, when I need the image for display reasons, I try to load them from my applicationStorageDirectory:

file = new File(File.applicationStorageDirectory.nativePath);

file = file.resolvePath("images/" + obj.id + extension);

image.load(new URLRequest(file.nativePath));

I made an output with both urls and they are identical. Nonetheless the image fails to load with error #2035.

In the desktop version of this application I store images in and load them from the applicationDirectory. This works fine!

Can anybody help?

Judith

This topic has been closed for replies.
Correct answer judith_sambs

I found the solution myself. If I want to load a file from the applicationStorageDirectory I must not reference it with file.nativePath but file.url !

judith

2 replies

judith_sambsAuthorCorrect answer
Inspiring
February 14, 2012

I found the solution myself. If I want to load a file from the applicationStorageDirectory I must not reference it with file.nativePath but file.url !

judith

February 21, 2012

Thanks. Work fine.