Take the 2-minute tour ×

I have a project (adobe AIR 3.1 - NOT flex) that is running on my webserver where nodeJS is installed. I'm looking at the possibility to call NodeJS javascript files from the AIR app. Like the AIR app collects some information and calls socket.io in NodeJS to dispatch the info to html connected clients. Is it possible ?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

This is certainly possible in the underlying protocols that socket io uses. I think there are a couple ways you can go about doing this:

  1. Use ExternalInterface and actually utilize the socket.io client library (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html)
  2. Send information to the node.js application in the same way that socket.io would use for Adobe Flash Socket, long polling, or even jsonp polling (http://socket.io/#browser-support)
  3. Write a shim and initiate a stream with it through native process (http://www.adobe.com/devnet/air/flex/quickstart/articles/interacting_with_native_process.html). You can even start the node.js application this way.

Overall, while its technically possible, I believe Adobe AIR isn't often used on the server side. Is there data from there that you can't get from only using node.js?

Just to clarify, socket.io is nice, but it is only fully utilized if you need bi directional communication. If you are only sending data from the AIR app to the node.js application, you have many options (ie, sending the data through an http service like REST/SOAP, etc..)

share|improve this answer
Well i did try something very simple and yet i have no idea why it doesn't work. I wrote a php page calling nodejs with javascript, and i call that php page in POST from AIR. If i call that page from my browser it works, but it doesn't work from the AIR app for some reason. Thanks for the suggestions tho, i will try to keep it simple... –  Eric Mar 16 '12 at 18:55
My question is now, can i call from AS3/AIR a php page in POST that runs a javascript ? The JS doesn't seem to run... –  Eric Mar 16 '12 at 19:13
Your software stack seems to be a big complex. If I'm understanding correctly, you're constructing a POST request to a php page which returns some javascript that itself uses some other protocol to talk to the node js application. You can just have AS3 talk directly to node js application using the same protocol that javascript is using. But I can see that it may be inconvenient (for example, maybe you're using some complex javascript library like socket.io...and that would imply porting it to as3). –  badunk Mar 16 '12 at 21:50
If you must use the PHP, there are 2 ways that might work. You can either use HTMLLoader (livedocs.adobe.com/flex/3/html/…) or StageWebView (adobe.com/devnet/air/quick_start_as/quickstarts/…) –  badunk Mar 16 '12 at 21:50
Thank you Duncan, it will read both :) –  Eric Mar 16 '12 at 22:10
add comment

Your Answer


