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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 143k
  • Answers 143k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer using LINQ list.Skip(fromRange).Take(toRange - fromRange) May 12, 2026 at 8:28 am
  • Editorial Team
    Editorial Team added an answer What is the 'cls' variable? Just create a new one… May 12, 2026 at 8:28 am
  • Editorial Team
    Editorial Team added an answer Tiles are simply logical chunks with which to organize your… May 12, 2026 at 8:28 am

Related Questions

I have an view-based application where the user can do a lot of customization
I wrote a small application to use as a sandbox for testing ideas that
To summarize, as we all know, a) Silverlight is expected to be hosted by
I'm sorry if this has already been asked, but I haven't been able to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.