Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 381

Programming actionscript 3.0
Table of Contents

Advertisement

The
LocalConnection.client
be invoked. In the previous code, the
class, CustomClient. The default value for the
LocalConnection instance. You can use the
that have the same set of methods but act differently—for example, in an application where a
button in one window toggles the view in a second window.
To create the CustomClient class, you could use the following code:
package
{
public class CustomClient extends Object
{
public function onMethod(timeString:String):void
{
trace("onMethod called at: " + timeString);
}
}
}
The third way to add callback methods, creating a dynamic class and dynamically attaching
the methods, is very similar to using the LocalConnection class in earlier versions of
ActionScript, as the following code shows:
import flash.net.LocalConnection;
dynamic class DynamicLocalConnection extends LocalConnection {}
Callback methods can be dynamically added to this class by using the following code:
var connection:DynamicLocalConnection = new DynamicLocalConnection();
connection.onMethod = this.onMethod;
// Add your code here.
public function onMethod(timeString:String):void
{
trace("onMethod called at: " + timeString);
}
The previous way of adding callback methods is not recommended because the code is not
very portable. In addition, using this method of creating local connections would could create
performance issues because accessing dynamic properties is dramatically slower than accessing
sealed properties.
Sending messages between two Flash Player
instances
You use the LocalConnection class to communicate between different instances of Flash
Player. For example, you could have multiple Flash Player instances on a web page, or have a
Flash Player instance retrieve data from a Flash Player instance in a pop-up window.
property indicates the object callback methods that should
property was set to a new instance of a custom
client
client
property if you have two data handlers
client
Connecting to other Flash Player instances
property is the current
381

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents