Hi I just started playing with Adobe Air. And I am using it with a javascript Library called Angular.
However, there is this line in the library that triggers Adobe Air’s sand box:
fn = Function('s', code);
On Adobe Air support page there is this sentence:
Calls to new Function(param, body) can be replaced with an inline function declaration or used only before the page load event has been handled.
Can you please explain to me what does inline function declaration mean and how to use it in general to achieve the same effect?
Thanks
JavaScript frameworks that use eval and the other blocked methods CAN work in Adobe Air, just not in the application sandbox.
See this document for details, but essentially you can get this to work by loading the page(s) which use the framework into a secondary frame. The top frame in Air is always considered the application sandbox, whereas any other frame runs in non-application mode, and therefore allows access to all of the blocked javascript methods.
http://help.adobe.com/en_US/air/html/dev/air_htmldevguide.pdf
Search for the section “Overview on configuring your HTML-based application”
Here is an example of a frameset which I have used to get around this problem
The magic is in the documentRoot and sandboxRoot attributes. Whatever is set as the documentRoot replaces the domain used in the sandboxRoot. Note that as a result the sandboxRoot doesn’t need to be a valid path.
In this instance the top frame loads a file called blank.html from the application into the application sandbox, hence this file can call the file system functions etc.. that the app sandbox has privileges to do.
The second frame will load “home.html” from the application directory, but it will load it into the non-application sandbox, which can contain pretty much any JavaScript framework which will run in Safari 4 (assuming you are using the latest version of the AIR runtime). This frame however cannot call secure AIR functions such as file system access.
If you want to call file system functions and other secure methods from the second frame, you will need to create a sandbox bridge, which is covered in the document I refer to above.
Hope this helps.