• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How do I communicate between an AIR application and a Flex application loaded through an HTMLLoader in AIR?

New Here ,
Aug 28, 2017 Aug 28, 2017

Copy link to clipboard

Copied

I have been trying to use LocalConnection, however I am getting an invalid argument error, so Im questioning whether or not this LocalConnection approach is even right:

AIR Application:

public function init() {

                var conn:LocalConnection;

                conn = new LocalConnection();

                conn.allowDomain("localhost");

                conn.connect("connection1");

                loadHTML();

}

private function loadHTML() {

                var urlReq:URLRequest = new URLRequest("http://localhost/myapp/");

                htmlUI.htmlLoader.load(urlReq);   

                visible=true;        

                //set attribute to allow external links to open in default system browser

                htmlUI.htmlLoader.navigateInSystemBrowser = true;

}

public function connect():void {

                trace("LOCAL CONNECTION SUCCEEDED");

}

FLEX Application:

private function doSomethingOnClick() : void {

    var conn:LocalConnection;

    conn = new LocalConnection();

    try {

        conn.send('app#MyAirApplication:connection1', 'connect');

    } catch (error:ArgumentError) {

        TIAlert.error(error.getStackTrace())

    }

}

TOPICS
Development

Views

434

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 30, 2017 Aug 30, 2017

Copy link to clipboard

Copied

RTFM LocalConnection

it's all here in the doc, in short you don't define a client for the function callback

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 30, 2017 Aug 30, 2017

Copy link to clipboard

Copied

I have it running when loading my Flex application through a local webserver, however when it's loaded in a server on a different machine the local connection doesn't seem to go through.

I understand that LocalConnection only works when the swf files are on the same machine, but shouldn't the AIR's HTMLLoader load the Flex application's swf file locally, and thus LocalConnection should work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 31, 2017 Aug 31, 2017

Copy link to clipboard

Copied

it can not work because you don't define a client for your LocalConnection

conn = new LocalConnection();

conn.client = ???

and so that can not work

conn.send('app#MyAirApplication:connection1', 'connect');

if you read the doc everything about the client part is explained

so let's be clear, when it does not work it's not because there is some issues with the API itself
it's because you are not following the doc to use it and/or your code sample is not really the one you are testing with

good luck

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2017 Aug 31, 2017

Copy link to clipboard

Copied

I said I have it running when loading my Flex application through a local webserver, meaning I have that part down already. Relax.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 31, 2017 Aug 31, 2017

Copy link to clipboard

Copied

I have the similar task to communicate between different SWF files. And we are suffering from ArgumentError bug:

Tracker

ArgumentError: Error #2082: Connect failed because the object is already connected.

May be this is your case too.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2017 Aug 31, 2017

Copy link to clipboard

Copied

LATEST

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines