Skip to main content
Participating Frequently
April 30, 2012
Question

How to link javascript files in myApp.app directory in IOS from html file in app StorageDirectory

  • April 30, 2012
  • 1 reply
  • 2209 views

I'm using Adobe Air 3 for IOS offline app, and I want to implement a download updates (html files + js,css) feature from within the application. The files would be displayed in a StageWebView component.

Since Apple doesn't allow saving files inside the installation directory, I must use ApplicationStorageDirectory instead to download files into.

I want those download html files to link to .js / .css files already installed within the main application directory (e.g. at myApp.app).

The reason for that is I want to minimize the number of the downloaded (shared) files as much as possible. Is this possible?

Thank you.

This topic has been closed for replies.

1 reply

sinious
Legend
April 30, 2012

http://help.adobe.com/en_US/air/html/dev/air_htmldevguide.pdf

app-storage:/path/to/code.js should work. Open that PDF, Chapter 2, Section 5, About URLs in AIR.

flashkidAuthor
Participating Frequently
May 1, 2012

I think this doesn't work in StageWebView:

http://help.adobe.com/en_US/air/build/WSfffb011ac560372f7e64a7f12cd2dd1867-8000.html#WS901d38e593cd1bac354f4f7b12e260e3e67-8000

"Note: Links in a StageWebView instance cannot open URLs that use a custom URI scheme."


So I can't for example do this:

<link rel="stylesheet" href="app:/CSS/Templates.css" type="text/css" media="screen, mobile" title="main" charset="utf-8">

What I need is something like the following:

Inside ApplicationStoarageDirectory (/Library/Application Support/):

     test.html

I need it to link to a css file located inside ApplicationDirectory (installation directory), something like:

     <link rel="stylesheet" href="../../MyApp.app/CSS/Templates.css" type="text/css" media="screen, mobile" title="main" charset="utf-8">


sinious
Legend
May 1, 2012

The File class can give you a path to any file you request:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html

e.g.

var myCSS:File = File.applicationStorageDirectory.resolvePath("css/some.css");

Then you can use myCSS.nativePath to get the full qualified OS path to the file.