O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

17.4. Accepting Communications from Other Domains

Problem

You want a movie to accept local connection communications from movies served from other domains.

Solution

Use the allowDomain( ) method of the receiving local connection object.

Discussion

By default, receiving movies accept communications from sending movies on the same domain only. However, you can use the allowDomain( ) method of a local connection object to allow or disallow communications from any domains. You need to define the allowDomain( ) method for each receiving local connection object for which you wish to define a custom list of domains to accept or deny.

If present, the allowDomain( ) method is automatically invoked when a local connection object receives a communication. If allowDomain( ) returns true, the communication is accepted; if it returns false, the communication is denied. Therefore, you can configure a local connection object to receive communications from any domain by having its allowDomain( ) method return true in all cases:

// Define the receiving local connection, and instruct it to listen to communications
// over the "_myConnection" channel.
receiving_lc = new LocalConnection(  );
receiving_lc.connect("_myConnection");

// Define the allowDomain(  ) method for the receiving local connection object, which
// is invoked automatically whenever a communication is received. This example always
// returns true, so all communications are accepted. receiving_lc.allowDomain = function (domain) { return true; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required