<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex the world &#187; 未分类</title>
	<atom:link href="http://www.flextheworld.com/category/uncategorized/feed" rel="self" type="application/rss+xml" />
	<link>http://www.flextheworld.com</link>
	<description>Flex, AIR, FMS, P2P and Things......</description>
	<lastBuildDate>Fri, 10 Sep 2010 08:08:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>基于Stratus 2的P2P多人文件共享</title>
		<link>http://www.flextheworld.com/2010/08/stratus2-p2p-fileshare.html</link>
		<comments>http://www.flextheworld.com/2010/08/stratus2-p2p-fileshare.html#comments</comments>
		<pubDate>Thu, 05 Aug 2010 12:43:40 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[Flex 迷你教程]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[flash multicast]]></category>
		<category><![CDATA[flash player 10.1]]></category>
		<category><![CDATA[Stratus]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=791</guid>
		<description><![CDATA[在我的上一篇Status 2的文章中给大家简单介绍了Stratus 2 一对多视频直播，今天给大家演示一下如何在NetGroup中共享文件。在原来的Strtuas 1 中，我们也可以发送文件，不过发送的方式很单一，只能通过NetStream.send的方式将文件发送给选定的对象。这样的文件发送问题很多。

发送过程中无法知道文件发送的情况。
很麻烦才可以将文件拆分发送。
发送的过程中很容易造成数据包丢失。
一次只能发送给一个用户，如果要发送到第二个用户，需要额外的连接。

以上这些问题因为Stratus 1 只支持点对点的传输，所以这些问题很难解决。而现在的Stratus 2，因为支持了Application level Multicast (应用层多播，关于应用层多播是什么因为不会影响我们的教程，这里就不多解释了，有兴趣的朋友可以问下google)，所以我们的文件发送变得更加的强大，或者说更加的P2P，具体来说有这些优点。

支持文件拆分发送。你可以将你的文件拆分至N份。
多用户间共享文件块 。A用户发送文件,B用户接收,C用户再接收时C用户从A与B中接收
相对稳定的传输 (因为Stratus 2 现在也是Beta阶段，我也没有试过真实环境下大量用户共享文件的情况所以稳定情况有待考证)
文件传输反馈。更方便的监控传送的过程

了解了以上这些，我们来看下面这个例子，代码我是在前一个例子的基础上添加，所以对已有的代码就不重复解释，只解释文件发送相关的代码。

文件发送过程

A从本地读取文件，切分成128K一个的大小，假设我们发送一个1MB的文件，那么就是9个文件块
A使用NetGroup.addHaveObject(0,9)发送文件, 9代表文件的快数。
B使用NetGroup.addWantObjects(index, index)来接收文件, 第一个index是当前的文件块，第二个index是需要到第几个文件块，我们的接收从0,0开始，我们在0文件块中保存文件的基本信息，名字，大小，等等。接收到0个文件快后，你可以直接接收剩下的全部文件块，比如NetGroup.addWantObjects(1, 9)，这样就直接接收剩全部文件块，如果NetGroup.addWantObjects(1, 1)表示你本次只需要再往下的一个文件块。
B在调用NetGroup.addWantObjects(index, index)后A会有事件响应，NetGroup.Replication.Request，在这个事件响应中A需要开始向要求文件的B发送文件 NetGroup.writeRequestedObject(event.info.requestID,p2pSharedObject.chunks[event.info.index])。 p2pSharedObject是我们发送的文件,requestID是B的地址，file.chunks[event.info.index]是需要写入的文件内容。
A发送文件时B响应事件NetGroup.Replication.Fetch.Result, B在事件中保存文件快，并继续重复#3步骤获取下一个文件快。如果文件块获取结束，保存本地。 （注意，B在获取文件块后可以使用#2的步骤将自己也变为文件发发布者）

Demo 操作
点击运行发布者
点击运行Viewer

先运行发布者，记住Gourp的名字，点击connect创建组
点击“共享文件”，随意选择一个文件。
运行Viewer，group中输入与发布者一样的Group.点击connect连接组
点击下载文件，下载发布者发送的文件。
你可以多开几个Viewer来一起接收文件。

需要注意的地方

?View Code ACTIONSCRIPT3     //允许Objecy Replication
     groupSpecifier.objectReplicationEnabled = true; //onConnect() function中设置


?View Code ACTIONSCRIPT3//设置replicationStrategy
netGroup.replicationStrategy = NetGroupReplicationStrategy.LOWEST_FIRST;//onNetGroupConnect() function中设置


?View Code ACTIONSCRIPT3//netStatusHandler中注意以下事件处理，接收和发送文件块
&#160;
case &#34;NetGroup.Replication.Fetch.Result&#34;: // e.info.index, e.info.object
&#160;
					//作为发布者已经接收的部分
					netGroup.addHaveObjects&#40;e.info.index,e.info.index&#41;;
					if&#40;e.info.code [...]]]></description>
			<content:encoded><![CDATA[<p>在我的上一篇Status 2的文章中给大家简单介绍了<a href="http://www.flextheworld.com/2010/02/flex-stratus-2-p2p.html" target="_blank">Stratus 2 一对多视频直播</a>，今天给大家演示一下如何在NetGroup中共享文件。在原来的Strtuas 1 中，我们也可以发送文件，不过发送的方式很单一，只能通过NetStream.send的方式将文件发送给选定的对象。这样的文件发送问题很多。</p>
<ol>
<li><span style="color: #ff0000;">发送过程中无法知道文件发送的情况。</span></li>
<li><span style="color: #ff0000;">很麻烦才可以将文件拆分发送。</span></li>
<li><span style="color: #ff0000;">发送的过程中很容易造成数据包丢失。</span></li>
<li><span style="color: #ff0000;">一次只能发送给一个用户，如果要发送到第二个用户，需要额外的连接。</span></li>
</ol>
<p>以上这些问题因为Stratus 1 只支持点对点的传输，所以这些问题很难解决。而现在的Stratus 2，因为支持了Application level Multicast (应用层多播，关于应用层多播是什么因为不会影响我们的教程，这里就不多解释了，有兴趣的朋友可以问下google)，所以我们的文件发送变得更加的强大，或者说更加的P2P，具体来说有这些优点。</p>
<ol>
<li><span style="color: #0000ff;">支持文件拆分发送。你可以将你的文件拆分至N份。</span></li>
<li><span style="color: #0000ff;">多用户间共享文件块 。A用户发送文件,B用户接收,C用户再接收时C用户从A与B中接收</span></li>
<li><span style="color: #0000ff;">相对稳定的传输 (因为Stratus 2 现在也是Beta阶段，我也没有试过真实环境下大量用户共享文件的情况所以稳定情况有待考证)</span></li>
<li><span style="color: #0000ff;">文件传输反馈。更方便的监控传送的过程</span></li>
</ol>
<p>了解了以上这些，我们来看下面这个例子，代码我是在前一个例子的基础上添加，所以对已有的代码就不重复解释，只解释文件发送相关的代码。</p>
<p><span id="more-791"></span></p>
<h2><strong>文件发送过程</strong></h2>
<ol>
<li>A从本地读取文件，切分成128K一个的大小，假设我们发送一个1MB的文件，那么就是9个文件块</li>
<li>A使用NetGroup.addHaveObject(0,9)发送文件, 9代表文件的快数。</li>
<li>B使用NetGroup.addWantObjects(index, index)来接收文件, 第一个index是当前的文件块，第二个index是需要到第几个文件块，我们的接收从0,0开始，我们在0文件块中保存文件的基本信息，名字，大小，等等。接收到0个文件快后，你可以直接接收剩下的全部文件块，比如NetGroup.addWantObjects(1, 9)，这样就直接接收剩全部文件块，如果NetGroup.addWantObjects(1, 1)表示你本次只需要再往下的一个文件块。</li>
<li>B在调用NetGroup.addWantObjects(index, index)后A会有事件响应，NetGroup.Replication.Request，在这个事件响应中A需要开始向要求文件的B发送文件 NetGroup.writeRequestedObject(event.info.requestID,p2pSharedObject.chunks[event.info.index])。 p2pSharedObject是我们发送的文件,requestID是B的地址，file.chunks[event.info.index]是需要写入的文件内容。</li>
<li>A发送文件时B响应事件NetGroup.Replication.Fetch.Result, B在事件中保存文件快，并继续重复#3步骤获取下一个文件快。如果文件块获取结束，保存本地。 （注意，B在获取文件块后可以使用#2的步骤将自己也变为文件发发布者）</li>
</ol>
<h2><strong>Demo 操作</strong></h2>
<p><a href="http://www.flextheworld.com/demo/stratus2-fileshare/Publisher.html" target="_blank"><span style="color: #ff0000;"><span style="color: #000000;"><strong><span style="color: #ff0000;">点击运行发布者</span></strong></span></span></a></p>
<p><a href="http://www.flextheworld.com/demo/stratus2-fileshare/Viewer.html" target="_blank"><span style="color: #ff0000;"><span style="color: #000000;"><strong><span style="color: #ff0000;">点击运行Viewer</span></strong></span></span></a></p>
<ol>
<li>先运行发布者，记住Gourp的名字，点击connect创建组</li>
<li>点击“共享文件”，随意选择一个文件。</li>
<li>运行Viewer，group中输入与发布者一样的Group.点击connect连接组</li>
<li>点击下载文件，下载发布者发送的文件。</li>
<li>你可以多开几个Viewer来一起接收文件。</li>
</ol>
<h2>需要注意的地方</h2>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p791code4'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7914"><td class="code" id="p791code4"><pre class="actionscript3" style="font-family:monospace;">     <span style="color: #009900; font-style: italic;">//允许Objecy Replication</span>
     groupSpecifier<span style="color: #000066; font-weight: bold;">.</span>objectReplicationEnabled = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//onConnect() function中设置</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p791code5'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7915"><td class="code" id="p791code5"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//设置replicationStrategy</span>
netGroup<span style="color: #000066; font-weight: bold;">.</span>replicationStrategy = NetGroupReplicationStrategy<span style="color: #000066; font-weight: bold;">.</span>LOWEST_FIRST<span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//onNetGroupConnect() function中设置</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p791code6'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7916"><td class="code" id="p791code6"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//netStatusHandler中注意以下事件处理，接收和发送文件块</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">&quot;NetGroup.Replication.Fetch.Result&quot;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #009900; font-style: italic;">// e.info.index, e.info.object</span>
&nbsp;
					<span style="color: #009900; font-style: italic;">//作为发布者已经接收的部分</span>
					netGroup<span style="color: #000066; font-weight: bold;">.</span>addHaveObjects<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">index</span><span style="color: #000066; font-weight: bold;">,</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">index</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">code</span> <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #990000;">&quot;NetGroup.Replication.Fetch.Result&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
						<span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #000000;">&#125;</span>
&nbsp;
					<span style="color: #009900; font-style: italic;">//接收文件</span>
					p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span>chunks<span style="color: #000000;">&#91;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">index</span><span style="color: #000000;">&#93;</span> = e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>object<span style="color: #000066; font-weight: bold;">;</span>
					updateStatus<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;正在接收第&quot;</span><span style="color: #000066; font-weight: bold;">+</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">index</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;块文件&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
					<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">index</span> == <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
						p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span>packetLenght = <a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>object<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span> = e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>object<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">;</span>
						updateStatus<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;要接收的文件有: &quot;</span><span style="color: #000066; font-weight: bold;">+</span>p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span>packetLenght<span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;块文件&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						receiveObject<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
					<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
						<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">index</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">&lt;</span>p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span>packetLenght<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
							receiveObject<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">index</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
						<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
							updateStatus<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;文件接收完毕&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
							updateStatus<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;接收了: &quot;</span><span style="color: #000066; font-weight: bold;">+</span>p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span>packetLenght<span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;块文件&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
							p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
							<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">&lt;</span>p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span>packetLenght<span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
								p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">writeBytes</span><span style="color: #000000;">&#40;</span>p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span>chunks<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
							<span style="color: #000000;">&#125;</span>
&nbsp;
							updateStatus<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;字节长度: &quot;</span><span style="color: #000066; font-weight: bold;">+</span>p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
							Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;保存文件&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;文件下载完毕，是否保存?&quot;</span><span style="color: #000066; font-weight: bold;">,</span>Alert<span style="color: #000066; font-weight: bold;">.</span>YES<span style="color: #000066; font-weight: bold;">|</span>Alert<span style="color: #000066; font-weight: bold;">.</span>NO<span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span>saveFileHandelr<span style="color: #000000;">&#41;</span>
&nbsp;
						<span style="color: #000000;">&#125;</span>
					<span style="color: #000000;">&#125;</span>
&nbsp;
					<span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">&quot;NetGroup.Replication.Request&quot;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #009900; font-style: italic;">// e.info.index, e.info.requestID</span>
					<span style="color: #009900; font-style: italic;">//同时作为发布者</span>
					netGroup<span style="color: #000066; font-weight: bold;">.</span>writeRequestedObject<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>requestID<span style="color: #000066; font-weight: bold;">,</span>p2pSharedObject<span style="color: #000066; font-weight: bold;">.</span>chunks<span style="color: #000000;">&#91;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">index</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>
					updateStatus<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;接收方ID: &quot;</span><span style="color: #000066; font-weight: bold;">+</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>requestID<span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;, 需要的文件块: &quot;</span><span style="color: #000066; font-weight: bold;">+</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">index</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
					<span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<h2>源文件下载</h2>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=26" title=" downloaded 56 times" >Stratus2FileSharing (56)</a>
<h2>相关资源</h2>
<ol>
<li><a title="Permalink to Flex 迷你教程 — 基于Stratus的P2P网络电话 (1)" rel="bookmark" href="http://www.flextheworld.com/2009/01/flex-stratus-p2p-phone.html">Flex 迷你教程 — 基于Stratus的P2P网络电话 (1)</a></li>
<li><a title="Permalink to Flex 迷你教程 — 基于Stratus的P2P网络电话 (2)" rel="bookmark" href="http://www.flextheworld.com/2009/01/flex-stratus-phone-2.html">Flex 迷你教程 — 基于Stratus的P2P网络电话 (2)</a></li>
<li><a href="http://www.flextheworld.com/2009/01/flex-stratus-phone-3.html" target="_blank">Flex 迷你教程 — 基于Stratus的P2P网络电话 (3)</a></li>
<li><a title="Permanent Link to Flex 迷你教程 — 基于Stratus 2的P2P在线视频共享1 (NetGroup, Multicast实例)" rel="bookmark" href="http://www.flextheworld.com/2010/02/flex-stratus-2-p2p.html">Flex 迷你教程 — 基于Stratus 2的P2P一对多视频直播 (NetGroup, Multicast实例)</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2010/08/stratus2-p2p-fileshare.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>收到Adobe寄来的小礼物</title>
		<link>http://www.flextheworld.com/2010/07/adobe-gift.html</link>
		<comments>http://www.flextheworld.com/2010/07/adobe-gift.html#comments</comments>
		<pubDate>Mon, 26 Jul 2010 14:12:14 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[我的事]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[adobe 礼物]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=759</guid>
		<description><![CDATA[今天收到了Adobe寄来的礼物，非常开心，Fiona在上周活动结束后说给我寄一些小礼物，没想到这么快就收到了，从大一开始就开始接触Flash，一路走到今天，Adobe也成为我最喜爱的公司。所以这次合肥的活动中认识几位Adobe的朋友真是非常开心，更开心的是能和大家一起分享自己各自的经验。未来的路还很长。希望Siloon, 自己和伙伴们可以越来越好，也希望Adobe未来可以提供给我们更多更强大的RIA框架:)
PS: 没想到的是礼物中有一张 “感谢信”，呵呵。很有纪念意义。






]]></description>
			<content:encoded><![CDATA[<p>今天收到了Adobe寄来的礼物，非常开心，Fiona在上周活动结束后说给我寄一些小礼物，没想到这么快就收到了，从大一开始就开始接触Flash，一路走到今天，Adobe也成为我最喜爱的公司。所以这次合肥的活动中认识几位Adobe的朋友真是非常开心，更开心的是能和大家一起分享自己各自的经验。未来的路还很长。希望<a href="http://www.siloon.com">Siloon</a>, 自己和伙伴们可以越来越好，也希望Adobe未来可以提供给我们更多更强大的RIA框架:)</p>
<p>PS: 没想到的是礼物中有一张 “感谢信”，呵呵。很有纪念意义。</p>
<p><a href="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5758.jpg" rel="shadowbox[post-759];player=img;"><img class="alignnone size-full wp-image-760" title="_MG_5758" src="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5758.jpg" alt="" width="720" height="480" /></a></p>
<p><span id="more-759"></span></p>
<p><a href="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5766.jpg" rel="shadowbox[post-759];player=img;"><img class="alignnone size-full wp-image-764" title="_MG_5766" src="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5766.jpg" alt="" width="720" height="480" /></a></p>
<p><a href="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5780.jpg" rel="shadowbox[post-759];player=img;"><img class="alignnone size-full wp-image-766" title="_MG_5780" src="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5780.jpg" alt="" width="720" height="480" /></a></p>
<p><a href="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5797.jpg" rel="shadowbox[post-759];player=img;"><img class="alignnone size-full wp-image-767" title="_MG_5797" src="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5797.jpg" alt="" width="720" height="480" /></a></p>
<p><a href="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5803.jpg" rel="shadowbox[post-759];player=img;"><img class="alignnone size-full wp-image-765" title="_MG_5803" src="http://www.flextheworld.com/wp-content/uploads/2010/07/MG_5803.jpg" alt="" width="720" height="480" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2010/07/adobe-gift.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>华东地区Adobe Flash平台技术研讨会归来</title>
		<link>http://www.flextheworld.com/2010/07/adobe-flash-meeting.html</link>
		<comments>http://www.flextheworld.com/2010/07/adobe-flash-meeting.html#comments</comments>
		<pubDate>Mon, 26 Jul 2010 13:28:19 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[我的事]]></category>
		<category><![CDATA[新闻]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[华东地区Adobe Flash平台技术研讨会]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=749</guid>
		<description><![CDATA[去合肥参加研讨会回来已经一周了，非常高兴能有机会参加这次会议，会场的气氛非常好，相信无论是我自己，还是每一位到场的朋友都在这次的活动中收获颇丰。也希望以后可以多参加这样的活动。
这里是活动的现场报道，你可以找到其他嘉宾的演讲PPT以及活动照片
艾瑞网报道华东Adobe Flash平台技术研讨会报道
这里是我的演讲PPT, 需要的朋友可以下载，过几天我会给我演讲视频
 
]]></description>
			<content:encoded><![CDATA[<p>去合肥参加研讨会回来已经一周了，非常高兴能有机会参加这次会议，会场的气氛非常好，相信无论是我自己，还是每一位到场的朋友都在这次的活动中收获颇丰。也希望以后可以多参加这样的活动。</p>
<p>这里是活动的现场报道，你可以找到其他嘉宾的演讲PPT以及活动照片</p>
<p><a href="http://bbs.airia.cn/riameeting/thread-14227-1-1.html" target="_blank"><span style="color: #800000;"><strong>艾瑞网报道华东Adobe Flash平台技术研讨会报道</strong></span></a></p>
<p>这里是我的演讲PPT, 需要的朋友可以下载，过几天我会给我演讲视频</p>
<p><span style="color: #800000;"><strong> <a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=25" title=" downloaded 51 times" >WEB&RIA (51)</a></strong></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2010/07/adobe-flash-meeting.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex 迷你教程 — 基于Stratus 2的P2P一对多视频直播 (NetGroup, Multicast实例)</title>
		<link>http://www.flextheworld.com/2010/02/flex-stratus-2-p2p.html</link>
		<comments>http://www.flextheworld.com/2010/02/flex-stratus-2-p2p.html#comments</comments>
		<pubDate>Wed, 24 Feb 2010 08:46:29 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[Flex 迷你教程]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[flash player 10.1]]></category>
		<category><![CDATA[Stratus]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=691</guid>
		<description><![CDATA[终于有时间试下Strtaus 2的p2p多播功能了。之前看的视频介绍中，Adobe描述一个非常理想的多人P2P数据共享方式。但是今天试了一下后发现视频的速度非常慢（视频的发布和接收端都在一台机器上），感觉上视频被发送到了什么地方后才传了回来。这这&#8230;&#8230;好吧，就当是BETA的问题了，WAIT AND SEE. (2/25日更新，2/23日发布的Flash player 10.1 beta 3 看来解决了这个问题，Demo的速度现在非常正常)
准备工作:
先了解一下什么是stratus以及什么是RTMFP，你可以到http://labs.adobe.com/technologies/stratus/看下官方的解释或者直接看我原来的 Flex 迷你教程 — 基于Stratus的P2P网络电话 (1)(2)(3) 先学习一下Flash p2p的基础. 简单的说原来的Stratus 实现了flash player之间点对点的传输数据，而今天要讲的stratus 2 不仅支持单个的点对点数据传说，还引入了多播的概念。
在原来的stratus中如果我们要做一个多人同时在线的应用，比如多人视频。那么我们需要把在线的所有人都链接起来，类似蜘蛛网的结构，网中的每个人需要与其他所有人链接，这样数据才能在所有人中共享。这种模式在多人连线中是不可取的。假设我们用户A发布一个视频想让其他10个用户观看，那么10个用户都需要链接到他。就中国的普通用户的网络带宽来说，这就是极限了。而Stratus 2 中 “组” 的概念解决了这个问题。用户A发布视频让同一个组中的其他10个人观看。他们并都从A处获取视频。而有可能通过组中的其他用户获取A的视频。这也就是P2P的模式了，每个人都可以作为数据的发出者，数据以最优的方式被观看者收到，参与的人越多，数据的副本就越多。视频的速度也就越快。


确定你安装了 Flex SDK3.2 以上的SDK (现在最新的是3.5). 这里下载
确定安装了flash payer 10.1 debug version (开发环境最好用debug version)  这里下载
申请一个 Stratus develper key 这里申请
下载flash player 10.1 的 Player Global SWC  这里下载，放到你的SDK3.2目录下面吧
导入下面的Demo源文件，编辑项目属性 — Flex compiler — Require Flash player version 到 10:1:0
编辑项目属性 [...]]]></description>
			<content:encoded><![CDATA[<p>终于有时间试下Strtaus 2的p2p多播功能了。之前看的视频介绍中，Adobe描述一个非常理想的多人P2P数据共享方式。但是今天试了一下后发现视频的速度非常慢（视频的发布和接收端都在一台机器上），感觉上视频被发送到了什么地方后才传了回来。这这&#8230;&#8230;好吧，就当是BETA的问题了，WAIT AND SEE. <strong><span style="color: #ff0000;">(2/25日更新，2/23日发布的Flash player 10.1 beta 3 看来解决了这个问题，Demo的速度现在非常正常)</span></strong></p>
<h2>准备工作:</h2>
<p><span style="font-weight: normal; font-size: 13px;">先了解一下什么是stratus以及什么是RTMFP，你可以到<a href="http://labs.adobe.com/technologies/stratus/">http://labs.adobe.com/technologies/stratus/</a>看下官方的解释或者直接看我原来的 <a href="http://www.flextheworld.com/2009/01/flex-stratus-p2p-phone.html">Flex 迷你教程 — 基于Stratus的P2P网络电话 (1)(2)(3</a>) 先学习一下Flash p2p的基础. 简单的说原来的Stratus 实现了flash player之间点对点的传输数据，而今天要讲的stratus 2 不仅支持单个的点对点数据传说，还引入了多播的概念。</span></p>
<p><span style="font-weight: normal; font-size: 13px;">在原来的stratus中如果我们要做一个多人同时在线的应用，比如多人视频。那么我们需要把在线的所有人都链接起来，类似蜘蛛网的结构，网中的每个人需要与其他所有人链接，这样数据才能在所有人中共享。这种模式在多人连线中是不可取的。假设我们用户A发布一个视频想让其他10个用户观看，那么10个用户都需要链接到他。就中国的普通用户的网络带宽来说，这就是极限了。而Stratus 2 中 “组” 的概念解决了这个问题。用户A发布视频让同一个组中的其他10个人观看。他们并都从A处获取视频。而有可能通过组中的其他用户获取A的视频。这也就是P2P的模式了，每个人都可以作为数据的发出者，数据以最优的方式被观看者收到，参与的人越多，数据的副本就越多。视频的速度也就越快。<span id="more-691"></span><br />
</span></p>
<ol>
<li>确定你安装了 Flex SDK3.2 以上的SDK (现在最新的是3.5). <a style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://www.adobe.com/products/flex/flexdownloads/" target="_blank">这里下载</a></li>
<li>确定安装了flash payer 10.1 debug version (开发环境最好用debug version)  <a style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://labs.adobe.com/downloads/flashplayer10.html" target="_blank">这里下载</a></li>
<li>申请一个 Stratus develper key <a style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;" href="https://www.adobe.com/cfusion/entitlement/index.cfm?e=stratus" target="_blank">这里申请</a></li>
<li>下载flash player 10.1 的 Player Global SWC  <a href="http://download.macromedia.com/pub/labs/flashplayer10/flashplayer10_globalswc.zip">这里下载</a>，放到你的SDK3.2目录下面吧</li>
<li>导入下面的Demo源文件，编辑项目属性 — Flex compiler — Require Flash player version 到 10:1:0</li>
<li>编辑项目属性 &#8212; Flex Builder Path &#8212; Library Path &#8212; Add SWC. 添加你刚才下载的playerglobal.swc &#8212;- 添加后双击playerglobal.swc &#8212; 双击Link Type &#8212; 切换Link Type到External</li>
</ol>
<p>好了，准备工作到此结束。</p>
<h2><strong>Demo操作</strong></h2>
<p>Demo 是一个视频共享的程序，用户A发布一个视频，其他进入相同组的用户可以观看视频，观看视频的同时大家可以文字聊天</p>
<ol>
<li>先运行Publisher.mxml. 点击链接 （记住Group 名字，一会要用）</li>
<li>运行Viewer.mxml, 输入刚才的Group 名字，点链接。</li>
<li>你可以运行多个Viewer,输入相同的Group名，链接进去同一个组</li>
<li>链接成功后Viewer可以看见Publisher发布的视频。下面的聊天框可以和所有人聊天。</li>
</ol>
<h2><strong>代码说明</strong></h2>
<p>具体的代码说明大家下载源文件看注释就好了（看Publisher的注释）。这里只说一下Publisher和Viewer的区别，Publisher是作为视频的发布者以及Group的参与者（注意他并不是Gruop的&#8221;老大&#8221;，Group对这里的任何人来说都是平等的，Publisher只是在里面发布了视频而已）。Viewer是视频的接收者以及Group的参与者。下面的代码指出了Viewer和Publisher的不同</p>
<p><strong>Publisher发布视频</strong></p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p691code9'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6919"><td class="code" id="p691code9"><pre class="actionscript3" style="font-family:monospace;">           <span style="color: #3f5fbf;">/**
            *
            * NetStraeam链接到用户组后触发
            * */</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onNetStreamConnect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
            	<span style="color: #009900; font-style: italic;">//加载话筒</span>
                netStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> mic<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=microphone%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:microphone.html"><span style="color: #004993;">Microphone</span></a> = <a href="http://www.google.com/search?q=microphone%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:microphone.html"><span style="color: #004993;">Microphone</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getMicrophone</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>mic<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    mic<span style="color: #000066; font-weight: bold;">.</span>codec = SoundCodec<span style="color: #000066; font-weight: bold;">.</span>SPEEX<span style="color: #000066; font-weight: bold;">;</span>
                    mic<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setSilenceLevel</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
                    netStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachAudio</span><span style="color: #000000;">&#40;</span>mic<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
                    updateStatus<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;话筒设置完毕<span style="">\n</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #009900; font-style: italic;">//加载视频，并发布视频和话筒</span>
                publishVideo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
            <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Viewer接收视频</strong></p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p691code10'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69110"><td class="code" id="p691code10"><pre class="actionscript3" style="font-family:monospace;">            <span style="color: #3f5fbf;">/**
            *
            * NetStraeam链接到用户组后触发
            * */</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onNetStreamConnect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                netStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
                <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000066; font-weight: bold;">!</span>= video<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    videoDisplay<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span>video<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    video = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
                video = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=video%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:video.html"><span style="color: #004993;">Video</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">smoothing</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
                video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachNetStream</span><span style="color: #000000;">&#40;</span>netStream<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                videoDisplay<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>video<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
                <span style="color: #009900; font-style: italic;">//播放视频</span>
                netStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;stream&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                netStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bufferTime</span> = <span style="color: #000000; font-weight:bold;">1.0</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h2>Demo截图</h2>
<p><strong>Publisher</strong></p>
<p><img class="alignnone size-full wp-image-694" title="a" src="http://www.flextheworld.com/wp-content/uploads/2010/02/a.png" alt="a" width="641" height="498" /></p>
<p><strong>Viewer</strong></p>
<p><img class="alignnone size-full wp-image-695" title="b" src="http://www.flextheworld.com/wp-content/uploads/2010/02/b.png" alt="b" width="642" height="547" /></p>
<h2>源代码下载</h2>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=24" title=" downloaded 480 times" >Stratus2Demo (480)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2010/02/flex-stratus-2-p2p.html/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>AIR 迷你教程 &#8212; 用AIR 2.0创建迷你Web服务器（ServerSocket 实例）</title>
		<link>http://www.flextheworld.com/2010/01/air-2-serversocket.html</link>
		<comments>http://www.flextheworld.com/2010/01/air-2-serversocket.html#comments</comments>
		<pubDate>Wed, 06 Jan 2010 07:33:34 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[AIR 迷你教程]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[AIR 2.0]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=660</guid>
		<description><![CDATA[AIR 2.0 一个非常重要的更新是支持了对Socket的监听，包括TCP (ServerSocket)以及UDP(DatagramSocket)。另外也支持了以UDP方式对外发送信息。这两个功能的增加无疑大大的增加了AIR的应用范围，比如&#8230;&#8230;&#8230;..这一下想个具体的还是比较困难，比如协作型的应用程序。
这篇教程将使用ServerSocket功能做一个HTML服务器，这个不是我原创的，是看到一个老外写的，觉得很有意思，是一个ServerSocket的好例子，原文在 http://coenraets.org/blog/2009/12/air-2-0-web-server-using-the-new-server-socket-api/. 原文是Flash Builder 4 版本的，这里我给大家的是Flex 3版本, 使用源代码请先下载AIR 2.0 SDK
Demo过程

下载安装 AIR 2.0 beta runtime.
下载MiniAIRWebServer.air
安装运行 MiniAIRWebServer.air.
运行 http://localhost:8765/HelloWorld.html （端口以你在运行MiniAIRWebServer.air后输入的为准, 注意安装MiniAIRWebServer.air后安装文件夹下的webroot/HelloWorld.html, 我们运行的就是这个文件）

运行效果如下:

源代码

?View Code ACTIONSCRIPT3&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;mx:WindowedApplication xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; close=&#34;closeHandler()&#34; creationComplete=&#34;init()&#34;&#62;
	&#60;mx:Script&#62;
		&#60;!&#91;CDATA&#91;
			import flash.events.Event;
            import flash.events.ProgressEvent;
            [...]]]></description>
			<content:encoded><![CDATA[<p>AIR 2.0 一个非常重要的更新是支持了对Socket的监听，包括TCP (ServerSocket)以及UDP(DatagramSocket)。另外也支持了以UDP方式对外发送信息。这两个功能的增加无疑大大的增加了AIR的应用范围，比如&#8230;&#8230;&#8230;..这一下想个具体的还是比较困难，比如协作型的应用程序。</p>
<p>这篇教程将使用ServerSocket功能做一个HTML服务器，这个不是我原创的，是看到一个老外写的，觉得很有意思，是一个ServerSocket的好例子，原文在 http://coenraets.org/blog/2009/12/air-2-0-web-server-using-the-new-server-socket-api/. 原文是Flash Builder 4 版本的，这里我给大家的是Flex 3版本, 使用源代码请先下载<a href="http://labs.adobe.com/downloads/air2.html" target="_blank">AIR 2.0 SDK</a></p>
<p>Demo过程</p>
<ol>
<li>下载安装 <a href="http://labs.adobe.com/downloads/air2.html" target="_blank">AIR 2.0 beta runtime</a>.</li>
<li>下载MiniAIRWebServer.air</li>
<li>安装运行 MiniAIRWebServer.air.</li>
<li>运行 http://localhost:8765/HelloWorld.html （端口以你在运行MiniAIRWebServer.air后输入的为准, 注意安装MiniAIRWebServer.air后安装文件夹下的webroot/HelloWorld.html, 我们运行的就是这个文件）</li>
</ol>
<p>运行效果如下:</p>
<p><img class="alignnone size-full wp-image-664" title="airserver" src="http://www.flextheworld.com/wp-content/uploads/2010/01/airserver.jpg" alt="airserver" width="341" height="235" /></p>
<p>源代码</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p660code12'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p66012"><td class="code" id="p660code12"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span>
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>WindowedApplication xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #990000;">&quot;vertical&quot;</span> <span style="color: #004993;">close</span>=<span style="color: #990000;">&quot;closeHandler()&quot;</span> creationComplete=<span style="color: #990000;">&quot;init()&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
	<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span>
		<span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
			<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span>ServerSocketConnectEvent<span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span>ServerSocket<span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=socket%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:socket.html"><span style="color: #004993;">Socket</span></a><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>Alert<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
&nbsp;
            <span style="color: #009900; font-style: italic;">//ServerSocket，用于监听TCP下的链接</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> serverSocket<span style="color: #000066; font-weight: bold;">:</span>ServerSocket<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> mimeTypes<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #009900; font-style: italic;">// 支持的类型</span>
                mimeTypes<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;.css&quot;</span><span style="color: #000000;">&#93;</span>     = <span style="color: #990000;">&quot;text/css&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                mimeTypes<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;.gif&quot;</span><span style="color: #000000;">&#93;</span>     = <span style="color: #990000;">&quot;image/gif&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                mimeTypes<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;.htm&quot;</span><span style="color: #000000;">&#93;</span>     = <span style="color: #990000;">&quot;text/html&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                mimeTypes<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;.html&quot;</span><span style="color: #000000;">&#93;</span>     = <span style="color: #990000;">&quot;text/html&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                mimeTypes<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;.ico&quot;</span><span style="color: #000000;">&#93;</span>     = <span style="color: #990000;">&quot;image/x-icon&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                mimeTypes<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;.jpg&quot;</span><span style="color: #000000;">&#93;</span>     = <span style="color: #990000;">&quot;image/jpeg&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                mimeTypes<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;.js&quot;</span><span style="color: #000000;">&#93;</span>     = <span style="color: #990000;">&quot;application/x-javascript&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                mimeTypes<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;.png&quot;</span><span style="color: #000000;">&#93;</span>     = <span style="color: #990000;">&quot;image/png&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
                <span style="color: #009900; font-style: italic;">// 初始化服务器文件夹</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> webroot<span style="color: #000066; font-weight: bold;">:</span>File = File<span style="color: #000066; font-weight: bold;">.</span>applicationStorageDirectory<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;webroot&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>webroot<span style="color: #000066; font-weight: bold;">.</span>exists<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    File<span style="color: #000066; font-weight: bold;">.</span>applicationDirectory<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;webroot&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>copyTo<span style="color: #000000;">&#40;</span>webroot<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> listen<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">try</span>
                <span style="color: #000000;">&#123;</span>
&nbsp;
                    serverSocket = <span style="color: #0033ff; font-weight: bold;">new</span> ServerSocket<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #009900; font-style: italic;">//监听链接</span>
                    serverSocket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CONNECT</span><span style="color: #000066; font-weight: bold;">,</span> socketConnectHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #009900; font-style: italic;">//绑定端口</span>
                    serverSocket<span style="color: #000066; font-weight: bold;">.</span>bind<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#40;</span>port<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #009900; font-style: italic;">//开始</span>
                    serverSocket<span style="color: #000066; font-weight: bold;">.</span>listen<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #004993;">log</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;正在监听 &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> port<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;端口...<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0033ff; font-weight: bold;">catch</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">error</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=error%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:error.html"><span style="color: #004993;">Error</span></a><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;端口 &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> port<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span> 
                        <span style="color: #990000;">&quot; 也许正在被使用，请尝试另一个端口.<span style="">\n</span>(&quot;</span> <span style="color: #000066; font-weight: bold;">+</span>
                        <span style="color: #004993;">error</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">message</span> <span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;)&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;错误&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> socketConnectHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span>ServerSocketConnectEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> socket<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=socket%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:socket.html"><span style="color: #004993;">Socket</span></a> = event<span style="color: #000066; font-weight: bold;">.</span>socket<span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #009900; font-style: italic;">//监听数据</span>
                socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">SOCKET_DATA</span><span style="color: #000066; font-weight: bold;">,</span> socketDataHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> socketDataHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">try</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> socket<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=socket%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:socket.html"><span style="color: #004993;">Socket</span></a> = event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span> <span style="color: #0033ff; font-weight: bold;">as</span> <a href="http://www.google.com/search?q=socket%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:socket.html"><span style="color: #004993;">Socket</span></a><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> bytes<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">readBytes</span><span style="color: #000000;">&#40;</span>bytes<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> request<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> bytes<span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #004993;">log</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= request<span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> filePath<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = request<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">substring</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span> request<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">indexOf</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;HTTP/&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> file<span style="color: #000066; font-weight: bold;">:</span>File = File<span style="color: #000066; font-weight: bold;">.</span>applicationStorageDirectory<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;webroot&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> filePath<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>file<span style="color: #000066; font-weight: bold;">.</span>exists <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">!</span>file<span style="color: #000066; font-weight: bold;">.</span>isDirectory<span style="color: #000000;">&#41;</span>
                    <span style="color: #000000;">&#123;</span>
                        <span style="color: #6699cc; font-weight: bold;">var</span> stream<span style="color: #000066; font-weight: bold;">:</span>FileStream = <span style="color: #0033ff; font-weight: bold;">new</span> FileStream<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                        stream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">open</span><span style="color: #000000;">&#40;</span> file<span style="color: #000066; font-weight: bold;">,</span> FileMode<span style="color: #000066; font-weight: bold;">.</span>READ <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                        <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">content</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                        stream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">readBytes</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">content</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                        stream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                        socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">writeUTFBytes</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;HTTP/1.1 200 OK<span style="">\n</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                        socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">writeUTFBytes</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Content-Type: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> getMimeType<span style="color: #000000;">&#40;</span>filePath<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span><span style="">\n</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                        socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">writeBytes</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">content</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #000000;">&#125;</span>
                    <span style="color: #0033ff; font-weight: bold;">else</span>
                    <span style="color: #000000;">&#123;</span>
                        socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">writeUTFBytes</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;HTTP/1.1 404 Not Found<span style="">\n</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                        socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">writeUTFBytes</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Content-Type: text/html<span style="">\n</span><span style="">\n</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                        socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">writeUTFBytes</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;&lt;html&gt;&lt;body&gt;&lt;h2&gt;Page Not Found&lt;/h2&gt;&lt;/body&gt;&lt;/html&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #000000;">&#125;</span>
                    socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">flush</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    socket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0033ff; font-weight: bold;">catch</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">error</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=error%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:error.html"><span style="color: #004993;">Error</span></a><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">error</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">message</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;错误&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> getMimeType<span style="color: #000000;">&#40;</span>path<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> mimeType<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">index</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = path<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lastIndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">index</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    mimeType = mimeTypes<span style="color: #000000;">&#91;</span>path<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">substring</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">index</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0033ff; font-weight: bold;">return</span> mimeType == <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000066; font-weight: bold;">?</span> <span style="color: #990000;">&quot;text/html&quot;</span> <span style="color: #000066; font-weight: bold;">:</span> mimeType<span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> closeHandler<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
            	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>serverSocket<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
            		serverSocket<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
            	<span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
	<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>HBox verticalAlign=<span style="color: #990000;">&quot;middle&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
        <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Label <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;Port:&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
        <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>TextInput id=<span style="color: #990000;">&quot;port&quot;</span> <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;8765&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;50&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
        <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;Listen&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;listen()&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
    <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>HBox<span style="color: #000066; font-weight: bold;">&gt;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>TextArea id=<span style="color: #990000;">&quot;log&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #000066; font-weight: bold;">/&gt;</span>
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>WindowedApplication<span style="color: #000066; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>下载:</p>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=19" title=" downloaded 310 times" >MIniAIRWebServer.air (310)</a>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=20" title=" downloaded 314 times" >MIniAIRWebServer.zip (314)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2010/01/air-2-serversocket.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>做中国最牛的即时视频聊天平台</title>
		<link>http://www.flextheworld.com/2009/09/halowei-update-ui.html</link>
		<comments>http://www.flextheworld.com/2009/09/halowei-update-ui.html#comments</comments>
		<pubDate>Wed, 30 Sep 2009 03:39:11 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[新闻]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[哈喽喂]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=619</guid>
		<description><![CDATA[哈喽喂今天升级了新的UI，以及一些新的功能。
点击 www.halowei.com 进入


]]></description>
			<content:encoded><![CDATA[<p>哈喽喂今天升级了新的UI，以及一些新的功能。</p>
<p>点击 <a href="http://www.halowei.com" target="_blank">www.halowei.com</a> 进入</p>
<p><img class="alignnone size-full wp-image-620" title="homepage" src="http://www.flextheworld.com/wp-content/uploads/2009/09/homepage.jpg" alt="homepage" width="491" height="515" /></p>
<p><img class="alignnone size-full wp-image-622" title="chat" src="http://www.flextheworld.com/wp-content/uploads/2009/09/chat.jpg" alt="chat" width="521" height="342" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/09/halowei-update-ui.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>QQ台球新人超级辅助外挂 &#8212; Snooker Assistan</title>
		<link>http://www.flextheworld.com/2009/03/qq-snooker-assista.html</link>
		<comments>http://www.flextheworld.com/2009/03/qq-snooker-assista.html#comments</comments>
		<pubDate>Mon, 09 Mar 2009 14:56:24 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[开源控件]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Plug in]]></category>
		<category><![CDATA[QQ 台球 外挂]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=435</guid>
		<description><![CDATA[朋友刚做好的QQ台球辅助外挂, 他的台球积分总是徘徊在-xxx分，有天终于爆发决定改变这种局面，身为专业人员当然要用专业的方法，于是这款Snooker Assistan外挂就此诞生。基于桌球碰撞理论用AIR开发了这款外挂，用上这个东西，新手的水平立马可以变成有1000场经验的中高手的水平。两天时间，朋友已以从以前的-300分刷0分了(不容易阿，终于不是负资产了)

使用方法:
打开程序后只有三个东西，一个十字架（做瞄准用），一个白球位置指示的圈圈，还有两个小点。使用时，先打开QQ桌球，切换到2D视图，确保焦点在瞄准器上，按方向键调整瞄准器的坐标，让十字架对准桌球窗口的左下角的十字架。然后拖动两个小点中的一个到目的洞，拖另一个到某个位置让两个小点之间的红线从目的球的正中穿过。之后就会发现白球位置的附近多了两个彩色的圈圈，那就是QQ桌球瞄准示意图的目的球的位置。只要你对准了这个位置，球就一定能进。信不？
但是有bug，一是角度不能太大，60度以内都没问题，太大了就不一定(看来理论还是有一点问题)。
对照截图: 


作者Albert Zhang Email: albert.zhang.sl@gmail.com
安装文件:
源文件下载:


]]></description>
			<content:encoded><![CDATA[<p>朋友刚做好的QQ台球辅助外挂, 他的台球积分总是徘徊在-xxx分，有天终于爆发决定改变这种局面，身为专业人员当然要用专业的方法，于是这款Snooker Assistan外挂就此诞生。基于桌球碰撞理论用AIR开发了这款外挂，用上这个东西，新手的水平立马可以变成有1000场经验的中高手的水平。两天时间，朋友已以从以前的-300分刷0分了(不容易阿，终于不是负资产了)</p>
<p><span id="more-435"></span></p>
<h3>使用方法:</h3>
<p>打开程序后只有三个东西，一个十字架（做瞄准用），一个白球位置指示的圈圈，还有两个小点。使用时，先打开QQ桌球，切换到2D视图，确保焦点在瞄准器上，按方向键调整瞄准器的坐标，让十字架对准桌球窗口的左下角的十字架。然后拖动两个小点中的一个到目的洞，拖另一个到某个位置让两个小点之间的红线从目的球的正中穿过。之后就会发现白球位置的附近多了两个彩色的圈圈，那就是QQ桌球瞄准示意图的目的球的位置。只要你对准了这个位置，球就一定能进。信不？<br />
但是有bug，一是角度不能太大，60度以内都没问题，太大了就不一定(看来理论还是有一点问题)。</p>
<h3><strong>对照截图: </strong></h3>
<p><strong><img class="alignnone size-full wp-image-436" title="snookerassistant" src="http://www.flextheworld.com/wp-content/uploads/2009/03/snookerassistant.jpg" alt="snookerassistant" width="720" height="540" /><br />
</strong></p>
<p style="text-align: center;">作者Albert Zhang Email: albert.zhang.sl@gmail.com</p>
<h3><strong>安装文件:</strong></h3>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=8" title=" downloaded 1296 times" >SnookerAssistant (1296)</a>
<h3><strong>源文件下载</strong>:</h3>
<p><!--easy2hide start--><br />
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=9" title=" downloaded 262 times" >SnookerAssistant.rar (262)</a><br />
<!--easy2hide end--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/03/qq-snooker-assista.html/feed</wfw:commentRss>
		<slash:comments>91</slash:comments>
		</item>
	</channel>
</rss>
