zoukankan      html  css  js  c++  java
  • LocalConnection

    AIR与AIR

    发送方

    ID :A

    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.net.LocalConnection;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.events.StatusEvent;
    import flash.text.TextFieldAutoSize;
    
    var conn: LocalConnection;
    
    LocalConnectionSenderExample();
    function LocalConnectionSenderExample() {
    	sendBtn.addEventListener(MouseEvent.CLICK, sendMessage);
    	sendBtn2.addEventListener(MouseEvent.CLICK, sendMessage2);
    	sendBtn3.addEventListener(MouseEvent.CLICK, sendMessage3);
    	conn = new LocalConnection();
    	conn.addEventListener(StatusEvent.STATUS, onStatus);
    }
    
    function sendMessage(event: MouseEvent): void {
    	conn.send("app#B:myConnection", "lcHandler", message.text);
    }
    
    
    function sendMessage2(event: MouseEvent): void {
    	conn.send("app#C:myConnection", "lcHandler", message.text);
    }
    
    
    function sendMessage3(event: MouseEvent): void {
    	conn.send("app#B:myConnection", "lcHandler", message.text);
    
    	conn.send("app#C:myConnection", "lcHandler", message.text);
    }
    
    function onStatus(event: StatusEvent): void {
    	//trace(event)
    	switch (event.level) {
    		case "status":
    			trace("LocalConnection.send() succeeded");
    			break;
    		case "error":
    			trace("LocalConnection.send() failed");
    			break;
    	}
    }
    

      接收方:

    ID:B

    import flash.display.Sprite;
    import flash.net.LocalConnection;
    import flash.text.TextField;
    
    
    var conn: LocalConnection;
    
     LocalConnectionReceiverExample();
    function LocalConnectionReceiverExample() {
    	
    	conn = new LocalConnection();
    	conn.client = this;
    	conn.allowDomain("app#A");
    	try {
    		conn.connect("myConnection");
    	} catch (error: ArgumentError) {
    		trace("Can't connect...the connection name is already being used by another SWF");
    	}
    }
    
    function lcHandler(msg: String): void {
    	output.appendText(msg + "
    ");
    }
    

      

      接收方:

    ID:C

    import flash.display.Sprite;
    import flash.net.LocalConnection;
    import flash.text.TextField;
    
    
    var conn: LocalConnection;
    
     LocalConnectionReceiverExample();
    function LocalConnectionReceiverExample() {
    	
    	conn = new LocalConnection();
    	conn.client = this;
    	conn.allowDomain("app#A");
    	try {
    		conn.connect("myConnection");
    	} catch (error: ArgumentError) {
    		trace("Can't connect...the connection name is already being used by another SWF");
    	}
    }
    
    function lcHandler(msg: String): void {
    	output.appendText(msg + "
    ");
    }
    

      

  • 相关阅读:
    tensorflow (七) k-means
    如何提升开发效率-前端技术选型篇
    Spring AOP详解
    Vue.js学习笔记-入门
    拥抱Vue,抛弃jQuery
    HTML+CSS实现审核流程步骤效果
    测试SpringMVC可能出现的线程安全问题
    CGLib动态创建对象和属性
    jconsole观察jvm中线程及GC情况
    Java NIO学习笔记-Selector
  • 原文地址:https://www.cnblogs.com/dt1991/p/14876077.html
Copyright © 2011-2022 走看看