zoukankan      html  css  js  c++  java
  • [ActionSprit 3.0] FMS远程共享

     1 package
     2 {
     3     import flash.display.Sprite;
     4     import flash.events.NetStatusEvent;
     5     import flash.events.SyncEvent;
     6     import flash.net.NetConnection;
     7     import flash.net.SharedObject;
     8     import flash.text.TextField;
     9     
    10     /**
    11      * @author Frost.Yen
    12      * @E-mail 871979853@qq.com
    13      * @create 2015-7-17 下午4:27:23
    14      *
    15      */
    16     public class SharedRemote extends Sprite
    17     {
    18         private var _nc:NetConnection = new NetConnection();
    19         private var _text:TextField = new TextField();
    20         private var _so:SharedObject;
    21         public function SharedRemote()
    22         {
    23             _text.x = 100;
    24             _text.y = 50;
    25             _text.autoSize = "left";
    26             this.addChild(_text);
    27             _nc.connect("rtmp://localhost/TestRemote");
    28             _nc.addEventListener(NetStatusEvent.NET_STATUS,onStatus);
    29         }
    30         private function onStatus(e:NetStatusEvent):void
    31         {
    32             trace("connected is: " + _nc.connected );
    33             trace("e.info.level: " + e.info.level);
    34             trace("e.info.code: " + e.info.code);
    35             switch (e.info.code)
    36             {
    37                 case "NetConnection.Connect.Success":
    38                     trace("Congratulations! you're connected");
    39                     _so = SharedObject.getRemote("testRemote", _nc.uri, true);
    40                     _so.connect(_nc);
    41                     var random:int = int(Math.random()*10000);
    42                     _so.addEventListener(SyncEvent.SYNC, onSync);
    43                     _so.data.text = "update data:"+random;
    44 //                    _so.setProperty("text","update data:"+random);
    45                     break;
    46                 case "NetConnection.Connect.Rejected":
    47                 case "NetConnection.Connect.Failed":
    48                     trace ("Oops! you weren't able to connect");
    49                     break;
    50             }
    51         }
    52         
    53         /*当共享数据发生更改时,更新客户端数据*/
    54         private function onSync(e:SyncEvent):void
    55         {
    56             trace(_so.data.text);
    57             _text.text = _so.data.text;
    58             
    59         }
    60     }
    61 }
  • 相关阅读:
    JSON和Object数组在js中的转换
    Raphael绘制箭头arrow
    Web后台框架开发
    数据库开发
    docker
    git
    linux
    正则表达式工具
    python模拟ls命令
    python3基础
  • 原文地址:https://www.cnblogs.com/frost-yen/p/4664731.html
Copyright © 2011-2022 走看看