9RIA.com天地会 - 论坛

返回列表 发帖

天地培训

9RIA天地会官方培训机构

Adobe官方认证培训中心

[新闻资讯] [业界动态] flash P2P中文api下载

  • 资讯类型:
  • 来源页面: http://cooerson.gicp.net/?p=295
  • 资讯原标题:
  • 资讯原作者: cooerson
  • 我的评论:
    对这篇文你有啥看法,跟贴说说吧!欢迎口水和板砖,哈哈。欢迎大家和我们一同分享更多资讯。

    把p2p直接相关的9个api翻译好了,现在就可以开始搞了嘿嘿。



    今天花了一天的时间重装系统,实在悲剧,原来是360出了问题导致系统崩溃+不能联网,至于是不是瑞星给360挂的马,就不得而知了。

    装好系统后,上360论坛,才稍稍有点安慰,不是我一个人重装了系统。360倒是及时提供了解决方案,但是我连网都上不了,你提供个方案顶啥用?气愤之下,暂时改用卡卡,正好瑞星一套。。。

    抱怨够了,还是来说说这个api,为了把新的地方和原来的api区别开,文字是加了粗的。还有就是我只翻译了上面的每个属性方法类似概述的注释,不过已经够用了。

    可以点这里下载中文API

    额,开始写例子咯~~~

    转载请注明:来自Cooerson’s BLOG && 9Ria
    原文地址:http://cooerson.gicp.net/?p=295

    附件: 您需要登录才可以下载或查看附件。没有帐号?注册
    3

    评分人数

    • smily

    • cwin5

    • yesman

    smily 赐本贴 银子 + 10  诏曰: 好帖!
    cwin5 赐本贴 银子 + 10  诏曰: 你就买个空间吧..
    yesman 赐本贴 银子 + 5  诏曰:

    qq86868007

    天地人才库
    顶起!!

    TOP

    我正想要这个啊

    TOP

    好兄弟,讲义气!---by eko

    踏上天地会荣耀之路!

     

    申请舵主

    加入掘金队

    加入译林军

    知识专题整理

     

    咨询(QQ):

    1442604479(小地)

     

    原文地址上不了。

    TOP

    flash p2p不是正在beta中吗?

    TOP

    好帖,值得顶
    半路程序员

    TOP

    一直在找这东西,哈哈

    TOP

    不得不顶一下,  就是看不懂英文。终于等到今天了!

    TOP

    本帖最后由 yanba 于 2010-2-4 11:34 编辑

    有cs5吗??

    TOP

    好东东啊好东东

    TOP

    下来看看。

    TOP

    楼主辛苦了

    TOP

    这个帮助落后了点,英文版一直在更新,所以现在还不适合翻译~

    这是英文版上提供的多人P2P例子
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    3.                                 layout="absolute"
    4.                                 width="100%"
    5.                                 height="100%"
    6.                                 applicationComplete="OnApplicationComplete()">
    7.         <mx:Script>
    8.                 <![CDATA[
    9.                         private var netConnection:NetConnection=null;
    10.                         private var netStream:NetStream=null;
    11.                         private var netGroup:NetGroup=null;
    12.                         private var video:Video=null;
    13.                         private var sequenceNumber:uint=0;
    14.                         private var resizeTimer:Timer=null;

    15.                         private const SERVER:String="rtmfp://stratus.adobe.com/";
    16.                         private const DEVKEY:String="YourStratusDeveloperKey";

    17.                         [Bindable]
    18.                         private var connected:Boolean=false;
    19.                         [Bindable]
    20.                         private var joinedGroup:Boolean=false;

    21.                         private function OnApplicationComplete():void
    22.                         {
    23.                                 userName.text="user " + int(Math.random() * 65536);

    24.                                 groupName.text="channel" + (int(Math.random() * 899) + 101);

    25.                                 resizeTimer=new Timer(2000.0);
    26.                                 resizeTimer.addEventListener(TimerEvent.TIMER, DoResizeVideo);
    27.                                 resizeTimer.start();
    28.                         }

    29.                         private function StatusMessage(msg:Object):void
    30.                         {
    31.                                 statusLog.text+=msg;
    32.                                 statusLog.verticalScrollPosition=statusLog.textHeight;
    33.                                 statusLog.validateNow();
    34.                         }

    35.                         private function NetStatusHandler(e:NetStatusEvent):void
    36.                         {
    37.                                 StatusMessage(e.info.code);
    38.                                 switch (e.info.code)
    39.                                 {
    40.                                         case "NetConnection.Connect.Success":
    41.                                                 OnConnect();
    42.                                                 break;

    43.                                         case "NetConnection.Connect.Closed":
    44.                                         case "NetConnection.Connect.Failed":
    45.                                         case "NetConnection.Connect.Rejected":
    46.                                         case "NetConnection.Connect.AppShutdown":
    47.                                         case "NetConnection.Connect.InvalidApp":
    48.                                                 OnDisconnect();
    49.                                                 break;

    50.                                         case "NetStream.Connect.Success": // e.info.stream
    51.                                                 OnNetStreamConnect();
    52.                                                 break;

    53.                                         case "NetStream.Connect.Rejected": // e.info.stream
    54.                                         case "NetStream.Connect.Failed": // e.info.stream
    55.                                                 DoDisconnect();
    56.                                                 break;

    57.                                         case "NetGroup.Connect.Success": // e.info.group
    58.                                                 OnNetGroupConnect();
    59.                                                 break;

    60.                                         case "NetGroup.Connect.Rejected": // e.info.group
    61.                                         case "NetGroup.Connect.Failed": // e.info.group
    62.                                                 DoDisconnect();
    63.                                                 break;

    64.                                         case "NetGroup.Posting.Notify": // e.info.message, e.info.messageID
    65.                                                 OnPosting(e.info.message);
    66.                                                 break;


    67.                                         case "NetStream.MulticastStream.Reset":
    68.                                         case "NetStream.Buffer.Full":
    69.                                                 DoResizeVideo();
    70.                                                 break;

    71.                                         case "NetGroup.SendTo.Notify": // e.info.message, e.info.from, e.info.fromLocal
    72.                                         case "NetGroup.LocalCoverage.Notify": //
    73.                                         case "NetGroup.Neighbor.Connect": // e.info.neighbor
    74.                                         case "NetGroup.Neighbor.Disconnect": // e.info.neighbor
    75.                                         case "NetGroup.MulticastStream.PublishNotify": // e.info.name
    76.                                         case "NetGroup.MulticastStream.UnpublishNotify": // e.info.name
    77.                                         case "NetGroup.Replication.Fetch.SendNotify": // e.info.index
    78.                                         case "NetGroup.Replication.Fetch.Failed": // e.info.index
    79.                                         case "NetGroup.Replication.Fetch.Result": // e.info.index, e.info.object
    80.                                         case "NetGroup.Replication.Request": // e.info.index, e.info.requestID
    81.                                         default:
    82.                                                 break;
    83.                                 }
    84.                         }

    85.                         private function DoConnect():void
    86.                         {
    87.                                 StatusMessage("Connecting to \"" + SERVER + "\" ...\n");
    88.                                 netConnection=new NetConnection();
    89.                                 netConnection.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);
    90.                                 netConnection.connect(SERVER + DEVKEY);
    91.                         }

    92.                         private function OnConnect():void
    93.                         {
    94.                                 var groupSpecifier:GroupSpecifier;

    95.                                 StatusMessage("Connected\n");
    96.                                 connected=true;

    97.                                 groupSpecifier=new GroupSpecifier("max2009lab/" + groupName.text);
    98.                                 groupSpecifier.multicastEnabled=true;
    99.                                 groupSpecifier.postingEnabled=true;
    100.                                 groupSpecifier.serverChannelEnabled=true;

    101.                                 netStream=new NetStream(netConnection, groupSpecifier.groupspecWithAuthorizations());
    102.                                 netStream.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);

    103.                                 netGroup=new NetGroup(netConnection, groupSpecifier.groupspecWithAuthorizations());
    104.                                 netGroup.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);

    105.                                 StatusMessage("Join \"" + groupSpecifier.groupspecWithAuthorizations() + "\"\n");
    106.                         }

    107.                         private function OnNetStreamConnect():void
    108.                         {
    109.                                 netStream.client=this;

    110.                                 var mic:Microphone=Microphone.getMicrophone();
    111.                                 if (mic)
    112.                                 {
    113.                                         mic.codec=SoundCodec.SPEEX;
    114.                                         mic.setSilenceLevel(0);

    115.                                         netStream.attachAudio(mic);

    116.                                         StatusMessage("got microphone\n");
    117.                                 }

    118.                                 var camera:Camera=Camera.getCamera();
    119.                                 if (camera)
    120.                                 {
    121.                                         camera.setMode(320, 240, 10);
    122.                                         camera.setQuality(30000, 0);
    123.                                         camera.setKeyFrameInterval(15);

    124.                                         videoDisplay.attachCamera(camera);
    125.                                         videoDisplay.maintainAspectRatio=true;

    126.                                         netStream.attachCamera(camera);

    127.                                         StatusMessage("got camera\n");
    128.                                 }

    129.                                 netStream.publish("stream");
    130.                         }

    131.                         private function OnNetGroupConnect():void
    132.                         {
    133.                                 joinedGroup=true;
    134.                         }

    135.                         private function DoDisconnect():void
    136.                         {
    137.                                 if (netConnection)
    138.                                         netConnection.close();
    139.                                 videoDisplay.attachCamera(null);
    140.                         }

    141.                         private function OnDisconnect():void
    142.                         {
    143.                                 StatusMessage("Disconnected\n");
    144.                                 netConnection=null;
    145.                                 netStream=null;
    146.                                 netGroup=null;
    147.                                 connected=false;
    148.                                 joinedGroup=false;
    149.                         }

    150.                         private function ClearChatText():void
    151.                         {
    152.                                 chatText.text="";
    153.                         }

    154.                         private function DoPost():void
    155.                         {
    156.                                 var message:Object=new Object;

    157.                                 message.user=userName.text;
    158.                                 message.text=chatText.text;
    159.                                 message.sequence=sequenceNumber++;
    160.                                 message.sender=netConnection.nearID;

    161.                                 netGroup.post(message);

    162.                                 StatusMessage("==> " + chatText.text + "\n");

    163.                                 chatText.callLater(ClearChatText);
    164.                         }

    165.                         private function OnPosting(message:Object):void
    166.                         {
    167.                                 StatusMessage("<" + message.user + "> " + message.text + "\n");
    168.                         }

    169.                         private function DoResizeVideo(ignored:*=null):void
    170.                         {
    171.                                 if (video)
    172.                                 {
    173.                                         if ((0 == video.videoHeight) || (0 == video.videoWidth))
    174.                                         {
    175.                                                 video.height=videoDisplay.height;
    176.                                                 video.width=videoDisplay.width;
    177.                                                 video.x=0;
    178.                                                 video.y=0;
    179.                                         }
    180.                                         else
    181.                                         {
    182.                                                 var videoAspect:Number=Number(video.videoWidth) / Number(video.videoHeight);
    183.                                                 var displayAspect:Number=Number(videoDisplay.width) / Number(videoDisplay.height);
    184.                                                 var adjustFactor:Number;

    185.                                                 if (videoAspect >= displayAspect) // video is wider than display
    186.                                                 {
    187.                                                         adjustFactor=Number(video.videoWidth) / Number(videoDisplay.width);
    188.                                                         video.width=videoDisplay.width;
    189.                                                         video.height=int(Number(video.videoHeight) / adjustFactor);
    190.                                                         video.x=0;
    191.                                                         video.y=int((videoDisplay.height - video.height) / 2);
    192.                                                 }
    193.                                                 else
    194.                                                 {
    195.                                                         adjustFactor=Number(video.videoHeight) / Number(videoDisplay.height);
    196.                                                         video.height=videoDisplay.height;
    197.                                                         video.width=int(Number(video.videoWidth) / adjustFactor);
    198.                                                         video.x=int((videoDisplay.width - video.width) / 2);
    199.                                                         video.y=0;
    200.                                                 }
    201.                                         }
    202.                                 }
    203.                         }

    204.                         public function onPlayStatus(info:Object):void
    205.                         {
    206.                         }

    207.                         public function onMetaData(info:Object):void
    208.                         {
    209.                         }

    210.                         public function onCuePoint(info:Object):void
    211.                         {
    212.                         }

    213.                         public function onTextData(info:Object):void
    214.                         {
    215.                         }

    216.                         public function ValidateConnectAllowed(isConnected:Boolean, groupNameText:String):Boolean
    217.                         {
    218.                                 return (!isConnected) && (groupNameText.length > 0);
    219.                         }
    220.                 ]]>
    221.         </mx:Script>

    222.         <mx:VBox top="10"
    223.                          right="10"
    224.                          left="10"
    225.                          bottom="10"
    226.                          verticalGap="6">
    227.                 <mx:HBox width="100%">
    228.                         <mx:Text text="Group:"/>
    229.                         <mx:TextInput id="groupName"
    230.                                                   width="100%"
    231.                                                   text="default"
    232.                                                   enabled="{!connected}"/>
    233.                         <mx:Button label="Connect"
    234.                                            click="DoConnect()"
    235.                                            enabled="{ValidateConnectAllowed(connected, groupName.text)}"/>
    236.                         <mx:Button label="Disconnect"
    237.                                            click="DoDisconnect()"
    238.                                            enabled="{connected}"/>
    239.                 </mx:HBox>
    240.                 <mx:VideoDisplay id="videoDisplay"
    241.                                                  width="320"
    242.                                                  height="240"
    243.                                                  resize="DoResizeVideo()"/>
    244.                 <mx:TextArea id="statusLog"
    245.                                          width="100%"
    246.                                          height="100%"/>
    247.                 <mx:HBox width="100%">
    248.                         <mx:TextInput id="userName"
    249.                                                   width="160"/>
    250.                         <mx:TextInput id="chatText"
    251.                                                   width="100%"
    252.                                                   enabled="{joinedGroup}"
    253.                                                   enter="DoPost()"/>
    254.                 </mx:HBox>
    255.         </mx:VBox>

    256. </mx:Application>
    复制代码
    www.xiaozhanchang.com
    小战场---打造属于flash的专业小游戏对战平台

    TOP

    回复 4# Y.Boy

    额,本机发布的,一般下午和晚上能上
    qq86868007

    TOP

    关于stratus beta2 新特性介绍,请看这篇帖子
    qq86868007

    TOP

    返回列表