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 + "
    ");
    }
    

      

  • 相关阅读:
    业务领域建模Domain Modeling
    用例建模Use Case Modeling
    分析一套源代码的代码规范和风格并讨论如何改进优化代码
    结合工程实践选题调研分析同类软件产品
    如何提高程序员的键盘使用效率?
    第一次博客作业
    python_同时迭代多个对象
    python_判断奇偶数
    印象笔记markdown使用笔记
    【转】A*算法解决八数码问题
  • 原文地址:https://www.cnblogs.com/dt1991/p/14876077.html
Copyright © 2011-2022 走看看