This is with FlexBuilder3. If you have a lot of javascript source files made on another project of yours (presuming to have used another technology like CF, .NET, Java) and you are intending to use those javascript source files while porting to Flex based AIR Application, then here is a sample to load all your javascripts and invoke the functions from With in the Flex application.
"Note: Adobe AIR currently does not support the ExternalInterface class" is clearly indicated in the API. So whats the alternative to this.
The API link for ExternalInterface.as (Search in AllClasses for ExternalInterface.as) also clearly indicates the following are possible:
From ActionScript, you can do the following on the HTML page:
- Call any JavaScript function.
- Pass any number of arguments, with any names.
- Pass various data types (Boolean, Number, String, and so on).
- Receive a return value from the JavaScript function.
So What we are going to do is "Load a dummy html page carrying links to all the javascript files to be invoked from the Flex AIR Application"...
Step 1: Get your js files into a directory

Step 2: Create a dummy html file and include your scripts as here

Step 3: use <mx:HTML /> tag of Adobe AIR to reference it in your app
![]()
Step 4: On Creation complete handler of your Adobe AIR application, load the html file which contains your js files, so you can reference it later on to invoke javascript functions...

Step 5: Use the reference as below and invoke a javascript function from within flex. You can pass arguments to the js function and retrieve return values as well.

0 comments:
Post a Comment