flex LocalConnection,2个swf之间通信

1,建对象。表示当前swf里面公用方法可以被外部访问。访问名字为(Protel_CTI_AGD_screenPOP)
private var screenPopLconn:LocalConnection;
screenPopLconn = new LocalConnection();
            screenPopLconn.client = this;
            try {
                screenPopLconn.connect("Protel_CTI_AGD_screenPOP");
            } catch (error:ArgumentError) {
                CTIlog.error("Can't connect...the connection name is already being used by another SWF");
            }

2,外部访问方法:
CTILocalConnection.send("Protel_CTI_AGD", "btvisb",null);//调用的一个实例
3,导入类:
package myas.agd.localConnection
{
import com.protel.cti.util.CTIlog;

import flash.events.StatusEvent;
import flash.net.LocalConnection;

public class CTILocalConnection
{
public function CTILocalConnection()
{
}
public static function send(localconnectionName:String,method:String,params:String):void
{
function onStatus(event:StatusEvent):void {
        switch (event.level) {
            case "status":
                //Alert.show("LocalConnection.send() succeeded");
                break;
            case "error":
                CTIlog.info("LocalConnection.send() failed");
                break;
        }
    }
var conn:LocalConnection = new LocalConnection();
conn.addEventListener(StatusEvent.STATUS, onStatus);
if(null==params){
conn.send(localconnectionName,method);
}
else
{
conn.send(localconnectionName,method,params);
}
}

}
}

你可能感兴趣的:(.net,Flex,Flash)