17.3. Validating Receipt of Communication Over a Local Connection


You want a sending movie to receive confirmation that the communication was successfully received.


Configure the receiving movie to return a receipt to the sending movie.


If you need to confirm that a communication was received, you can have the receiving movie send a message back to the original sending movie. Here are the steps for confirming receipt of a communication:

  1. Set up the sending and receiving movies, as described in Recipe 17.1.

  2. In addition to whatever code you include in the method that is invoked on the receiving movie, write code to send a receipt over a new channel (e.g., “_myConnectionReceipt”). You can use this.send( ) within the local connection’s method to send a receipt back to the original sender.

  3. In the sending movie, call the connect( ) method, passing it the name of the channel over which the receiving movie sends the receipt (again, “_myConnectionReceipt”).

  4. In the sending movie, create a method on the local connection object to handle the receipt communication. Make sure this method name matches the name of the method that the receiving movie invokes when sending the receipt.

The following is an example of some code from a sending movie and a receiving movie.

First, the receiving movie code:

// Create the receiving code to listen on the "_myConnection" channel. lc = new LocalConnection( ); lc.connect("_myConnection"); lc.myMethod = function ( ) { // In addition to whatever ...

Get Actionscript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.