USING LOCALCONNECTION TO Communicate Between Two flex Applications

xiaoxiao2021-03-06  41

Several Customers in the Early Adopter Program have asked me if two Flex applications running on the same machine can communicate with each other The answer is yes:. The LocalConnection class allows a Flex application to send data to- and trigger events in another Flex application running On The Same Machine. Here Is A Simple Example: 1. "Sending" Application (Run It!) var myConnection; function initialize () {myConnection = new LocalConnection (); myConnection.onStatus = mx.utils.Delegate. create (this, onStatus);} function sendMessage () {myConnection.send ( "application_b", "messagePosted", myMessage.text);} function onStatus (result) {status.text = result.level == "error"? "Operation Failed": "Operation successmeded";} Code Highlights:

myConnection = new LocalConnection (); Create an instance of the LocalConnection class myConnection.onStatus = mx.utils.Delegate.create (this, onStatus); The onStatus event is triggered after the send () method is invoked to allow you to respond to the success or failure of the operation myConnection.send ( "receivingapp", "messagePosted", myMessage.text); "reveivingapp" is the name the receiving app used to connect "messagePosted" is the event to trigger in the receiving applicationmyMessage.text Is The Data To Pass To The Receiving Application. You CAN Pass Objects or Multiple CommA-Separated Values.2. "Receiving" Application

Run it!)

Code highlights

转载请注明原文地址:https://www.9cbs.com/read-86186.html

New Post(0)