Communication Between Flash Movies with ActionScript
From Flash Player 6, Flash developers can use Local Connections to communicating between Flash Movie. Local Connection provide a much easier means that Flash movies can broadcast to and listen for broadcasts from any other movie on the same computer.
Basic Concept of Flash Movies Communication:
Communication between Flash Movies can easily be achieved by using Local Connection. The basic concepts is that:
- the sender Flash Movie sending broadcasts to other receiver Flash Movie,
- the receiver Flash Movie is listening to broadcasts sending from the sender Flash Movie.
Of course you have to set up connection between the sender Flash Movie and the receiver Flash Movie.
Basic steps setting up communication between flash movies.
Sender Flash Movie://The first step is to create a LocalConnection object.
var receiverLC:LocalConnection = new LocalConnection();
// Use LocalConnection.send( ) to call a function in the receiver movie.
receiverLC.send("_myConnection", "functionInReceiver");
Receiver Flash Movie:
//Create a LocalConnection object.
var receiverLC:LocalConnection = new LocalConnection();
// Use LocalConnection.connect( ) to listen for any messages
receiverLC.connect("_myConnection");
//Define the function that will be called upon from the sender.
function functionInReceiver ():void {
doAnyThing.......;
}
The whole stroy of how Flash Movies communicate with each others is explained in the following diagram:
Remarks:
This Flash ActionScript tutorial shows how Flash Movies communicate with each others.