1 Reply Latest reply on Nov 20, 2010 6:41 AM by commadelimited

    Calling JS functions from AIR

    >Vee< Level 1

      Problem: I have a bunch of .js files that I would like to not share with the world. Instead, I would like to create an AIR application (desktop only) that can make use of the JS functions without including the .js files to the people I give the AIR app too.

       

      Question: Is there a way to do this? I'm familiar with developing applications with as3 but not for AIR at all.

       

      Sample code:

      as code:

      var returnValue:String = ExternalInterface.call("sendReturn",tempStr).toString();
      

       

      bla.js

      function sendReturn(val){
                alert(val);
                var tempData = "Hello from JS";       return tempData + ' :return'; }
      
      

        • 1. Re: Calling JS functions from AIR
          commadelimited Level 2

          If your application is written with JavaScript then your only options are as follows:

           

          1) Embed all your JS in the installed application. These files are installed as plain text files on the users computer and can be opened and viewed.

          2) Load the javascript files remotely, then parse them using a JSON parser such as can be found at json.org or https://github.com/douglascrockford/JSON-js

          3) Use the security sandbox to load remote files inside an iframe or similar device to avoid AIR's security restrictions.