3

I am creating an android application in flash builder 4 using 4.1 SDK on windows. The application first downloads some images from the internet and saves them in the desktopDirectory. Now I want to display downloaded images in my flex mobile application.

Issue:

Images are being downloaded from the internet successfully and saved in the desktopDirectory successfully.

Now when I try to display an image using nativePath then it is not displayed. A small blue icon with a questionmark is displayed instead of the image. The code that I am using is as below:

displayContainer.removeAllElements();
var image:spark.components.Image = new spark.components.Image();
var imageFile:File = File.desktopDirectory.resolvePath(desktopFilePath);
if(imageFile.exists)
{
    var imagePath:String = File.desktopDirectory.resolvePath(desktopFilePath).nativePath;

    image.source = imagePath;
    trace("Image Path: " + imagePath);
    displayContainer.addElementAt(image,1);
}

When I trace if the image file exists or not, it shows that the file is there. But the file is not displayed in the app.

However, the image is displayed when I hardcode the image path in the code as below:

<s:Image id="a1" source="data/02.jpg" />

Thus the image is there but the path is not being resolved programmatically.

What am I doing wrong? Please guide.

I am testing my application on an android tablet.

ketan
  • 19,129
  • 42
  • 60
  • 98
Vivek
  • 663
  • 2
  • 13
  • 40

1 Answers1

3

Instead of using file nativePath, I used file url and I got solution to my problem. Please see the code below which is working:

displayContainer.removeAllElements();
var image:spark.components.Image = new spark.components.Image();
var imageFile:File = File.desktopDirectory.resolvePath(desktopFilePath);
if(imageFile.exists)
{
    var imagePath:String = File.desktopDirectory.resolvePath(desktopFilePath).url;

    image.source = imagePath;
    trace("Image Path: " + imagePath);
    displayContainer.addElementAt(image,1);
}
Vivek
  • 663
  • 2
  • 13
  • 40