Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 137583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:07:44+00:00 2026-05-11T07:07:44+00:00

So I have an Application Sandbox HTMLLoader object which I create in AIR and

  • 0

So I have an Application Sandbox HTMLLoader object which I create in AIR and simply want to call ActionScript methods from JavaScript. In Flash, this is accomplished through our trusty ExternalInterface.addCallback() function. However in AIR, things are quite a bit different, and I just can’t seem to get it to work.

Here is a simplified overview of my project:

My AIR (ActionScript) main:

public class Main extends Sprite {      public var _as3Var:String = 'testing';     public function as3Function():void     {         trace('as3Function called from Javascript');     }      public function Main() {         NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke);     }      protected function onInvoke(e:InvokeEvent):void {         NativeApplication.nativeApplication.removeEventListener(InvokeEvent.INVOKE, onInvoke );         var app = new App();         addChild(app);         app.init(new ExternalContainer(), e.currentDirectory, e.arguments);     } } 

And this is how I create my HTMLLoader object:

{     _html = new HTMLLoader();     _html.useCache = false;     _html.runtimeApplicationDomain = ApplicationDomain.currentDomain;     _html.load(new URLRequest('sandbox/AirRoot.html'));     _html.width = 800;     _html.height = 600;     App.ref.addChild(_html); } 

And at last, here is my snippet of JavaScript in my AirRoot.html file which is trying to call the public method as3Function() declared in my Main class:

Exposed.testAs3 = function() {     air.trace('Exposed.testAs3 called');            /* This works fine. */     air.trace('runtimeVersion:');                   /* This works fine. */     air.trace(air.NativeApplication.nativeApplication.runtimeVersion);  /* This works fine. */     air.trace('seeing if I can get to AS3 params...');  /* This works fine. */      /* This doesn't work - get the following error: TypeError: Value undefined does not allow function calls. */     air.NativeApplication.nativeApplication.as3Function(); } 

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:07:45+00:00Added an answer on May 11, 2026 at 7:07 am

    OK, I am going to answer my own question. I promise this was not a ploy to gain more reputation points, but I was seriously confused today but have now found the appropriate answers and documentation – which is usually the main problem to many an engineer’s question…

    Anyway, the answer:

    The AIR HTMLLoader object contains a magical property, HTMLLoader.window, which is a proxy to the JavaScript window object. So setting HTMLLoader.window = AS3Function; is one way – or in relation to my previously included example (assuming I setup a static property called Main which pointed to the Main class):

    _html.window.as3Function = Main.as3Function; 

    And now in JavaScript I can just call as3Function as:

    <script>     window.as3Function(); </script> 

    Another interesting property is the JavaScript ‘window.htmlLoader’ object. It is a proxy to the AS3 HTMLLoader parent object, in my case, the _html object. From this you can access things in relation to the _html object from JavaScript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Symfony 1.2.4 application, taken and modified from the Symfony sandbox application
I have application which needs to use a dll (also written by me) which
I have created the application which is based on Sqlite database. So in my
In an effort to create a sandbox for CoreGraphics development (which currently consists of
I have implemented In App purchase in my application. While testing (with SandBox environment),
I have an application which goes out to the internet and collects XML article
I am working on a project that i want to have a plugin-sandbox like
My project stopped building from a fresh sandbox. I have an inplace plugin configured
I have application that makes different queries with different results so the caching in
I have Application settings stored under HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany branch. Settings must be same for different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.