• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

what should I do to overwrite my embed file (AIR app)

Contributor ,
Jan 10, 2018 Jan 10, 2018

Copy link to clipboard

Copied

Hi,

I've got an AIR map that displays the tides.

The tides are in an xml file that I embed to my apk or ipa like this :

WtFFO.png

I'd like to have the possibility to overwrite this file. Problem : I don't know if AIR allows me to write or overwrite anything in the app directory.

I've tried this :

function startDownload():void{
var urlString:String = "http://mywebsite/horaires3.xml";
var urlReq:URLRequest = new URLRequest(urlString);
var urlStream:URLStream = new URLStream();
var fileData:ByteArray = new ByteArray();
urlStream.addEventListener(Event.COMPLETE, loaded);
urlStream.load(urlReq);


function loaded(event:Event):void {
urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);
writeFile();
}

function writeFile():void {
var file:File = File.applicationStorageDirectory.resolvePath("horaires3.xml");
var fileStream:FileStream = new FileStream()
fileStream.open(file, FileMode.WRITE);
    urlRemote_txt.text = file.url;
fileStream.writeBytes(fileData, 0, fileData.length);
fileStream.close();
trace("The AIR file is written.");
}

}

The new xml file is downloaded, no errors, but it doesn't seems to replace the original xml of the app..

link of the downloaded xml = app-storage:/horaires3.xml

link of the original xml = horaires3.xml

So, what do you suggest me to do ?

Is there a way to overwrite it ?

TOPICS
ActionScript

Views

312

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 10, 2018 Jan 10, 2018

Copy link to clipboard

Copied

Pretty sure you can't on iOS, and possibly not an Android either. The normal approach would be to copy the file to the application's storage directory. Read this article:

File - Adobe ActionScript® 3 (AS3 ) API Reference

but there isn't an exact example for what you need. It's the middle of the night for me at the moment, but I have had to do something similar. If you can't work it out I'll try to find some of my code in the morning.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 10, 2018 Jan 10, 2018

Copy link to clipboard

Copied

LATEST

Ok Thx. I'll try it tomorrow (night for me too)

I'll let you know

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines