数据加载中……
use localConnection to comunicate between SWF
Flex local connection is an amazing functionality. With it, you can have two SWF comunicate easily.

Here is a simple example to demonstrate how it work base on Adobe training and my practice.

On Sender(client) side:
 <mx:Script>
  <![CDATA[
   import flash.net.LocalConnection;   //do the import
   private var conn:LocalConnection; 
   
   private function init():void{
    conn = new LocalConnection();  // create a new local connection instance
    conn.send("_mylocalconnection", "doCloseAgentPopup");  //send request to receiver(server) side. "_mylocalconnection" is kind of connection node. 
                                                                                            // "doCloseAgentPopup" is the function to call. you can also use some parameters followed it
   }
  ]]>
 </mx:Script>

On Receiver(server) side:
    import flash.net.LocalConnection;
    private  var conn:LocalConnection;
           
   private function initLocalConn():void
   {
    conn = new LocalConnection();
    conn.client = this;    // notice that this is called "client" here. I think it mean it is a client to provide service to other side.
    conn.connect("_mylocalconnection");    // connect to the node "_mylocalconnection" and wait call from other side
   }
   
   public function doCloseAgentPopup():void{        //this is the function to call from sender side. in this function, do general flex funtion as you like
    if(MyTitleWindow != null){
     PopUpManager.removePopUp(agentTitleWin);
     agentTitleWin = null;
     checkAgentStatus();
    }
   }

That is it. simple but work well. Enjoy it!

posted on 2009-07-02 21:27 yellowstone 阅读(266) 评论(0)  编辑  收藏 所属分类: flex 3 -- blazeds


只有注册用户登录后才能发表评论。


网站导航: