Saving/Reading a file from File.applicationStorageDirectory in an iPad Flex4.5 app

I have a Flex application (SDK 4.5.1) which runs on iPad... I need to download any files, put them in local directory (like the File.applicationStorageDirectory) and then view the file inside my application.

So in my test application a downloaded a png image using the urlLoader class.

Here it is the complete handler of the download:

private function onComplete3(event:Event):void{
    var ba:ByteArray  = as ByteArray;
    var file:File=File.applicationStorageDirectory.resolvePath("img.png");
    var pathFile:String = file.nativePath;
    var fileStream:FileStream = new FileStream();, FileMode.WRITE);  
    fileStream.addEventListener(Event.CLOSE, fileClosed);  
       status0.text = "STATE : ERROR 3"
    status0.text = "STATO : OK";
    path0.text = pathFile; 
    immagine0.source = pathFile; 
    status0.text = "STATE : ERROR 2"

On my iPad I can see the downloaded file exists, but when I run the line immagine0.source = pathFile (which is an image component), nothing appears... Maybe I can write a file but I cannot read it?


After 6 hours of debug and coding...i solved this problem with a very simple solution... changed the line

var pathFile:String = file.nativePath;


var pathFile:String = file.url;

He solved the file.url in this way:


.Now it works! Hope this post will be helpful for someone other have this problem..Thanks to all

Need Your Help

Creating a random that selects ONE integer

java random

I need to make a random that selects ONE integer, all the code that I have tried generates 2 integers. Here is my current code for a random int: