<?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; FMS</title>
	<atom:link href="http://www.flextheworld.com/tag/fms/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>Flex 迷你教程 — 基于Stratus的P2P网络电话 (3)</title>
		<link>http://www.flextheworld.com/2009/01/flex-stratus-phone-3.html</link>
		<comments>http://www.flextheworld.com/2009/01/flex-stratus-phone-3.html#comments</comments>
		<pubDate>Sat, 17 Jan 2009 14:40:07 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[Flex 迷你教程]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[FMS]]></category>
		<category><![CDATA[Stratus]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=276</guid>
		<description><![CDATA[在Flex 迷你教程 — 基于Stratus的P2P网络电话 (2)中我们已经知道如何链接一个客户端并且互相发送短信，今天来扩展下面的这些内容

呼叫时在被呼叫端显示 &#8220;接受&#8221;，点击接受后双方建立链接。
呼叫试或者接通后可以挂机。
添加视频与音频通信。

首先来看看Demo:
Demo 操作:
1. 输入任意名称，点击链接 （两台机器或者两个浏览器）
2. 输入对方的peerId，点击呼叫
3. 被呼叫方点击 &#8220;接受&#8221; 建立链接。
4. 开始语音，视频，文字通讯.
5. 挂机
Demo地址:
http://flextheworld.com/flash/p2p/P2pPhoneDemo.html

Demo截图:

新添加的代码
首先是修改call() function, 根据不同的label执行不同的事件，如果callYou.label是 &#8220;接受&#8221;，执行accpetHandle()与呼叫者建立链接，如果是&#8221;挂断&#8221;，那么执行hangup()挂断双方的通讯，如果是其他(也就是&#8221;呼叫&#8221;)，则执行后面的内容。
呼叫时调用publishVide和publishAudio将视频与音频附加到outgoingStream发送。在onConnectSuccesss事件中播放被呼叫者返回的视频和音频。监听onHangup事件来控制挂断。呼叫时将“呼叫”改为“挂断”。

?View Code ACTIONSCRIPT3//呼叫对方的方法，现在是呼叫者角色
private function call&#40;&#41;:void&#123;
&#160;
if&#40;callYou.label == &#34;接受&#34;&#41;&#123;
accpetHandle&#40;&#41;;
callYou.label = &#34;挂断&#34;
return;
&#125;else if&#40;callYou.label == &#34;挂断&#34;&#41;&#123;
outgoingStream.send&#40;&#34;onHangup&#34;&#41;
this.hangup&#40;&#41;
&#160;
return;
&#125;
&#160;
...............
&#160;
//发送视频
publishVideo&#40;&#41;;
//发送音频
publishAudio&#40;&#41;
&#160;
..........
&#160;
//监听onConnectSuccess事件，确定链接成功
i.onConnectSuccess = function&#40;name:String&#41;:void
&#123;
info.text += &#34;与&#34;+name + &#34;链接成功n&#34;;
sendMessageBtn.enabled = true;
incomingStream.receiveAudio&#40;true&#41;
incomingStream.receiveAudio&#40;true&#41;
remoteVideo = new Video&#40;&#41;;
remoteVideo.width = 160;
remoteVideo.height = 120;
remoteVideo.attachNetStream&#40;incomingStream&#41;;
remoteVideoDisplay.addChild&#40;remoteVideo&#41;;
sendMessageBtn.enabled = true;
&#125;
&#160;
i.onHangup = function&#40;&#41;:void&#123;
hangup&#40;&#41;
&#125;
&#160;
incomingStream.client = i
&#160;
callYou.label = &#34;挂断&#34;

被呼叫者在监听到呼叫者的呼叫时不马上回应，只是提示被呼叫者 “正在被链接”，同时将“呼叫”改为“接受”, 监听onHangup事件

?View Code [...]]]></description>
			<content:encoded><![CDATA[<p>在<a href="http://www.flextheworld.com/2009/01/flex-stratus-phone-2.html" target="_blank">Flex 迷你教程 — 基于Stratus的P2P网络电话 (2)</a>中我们已经知道如何链接一个客户端并且互相发送短信，今天来扩展下面的这些内容</p>
<ol>
<li>呼叫时在被呼叫端显示 &#8220;接受&#8221;，点击接受后双方建立链接。</li>
<li>呼叫试或者接通后可以挂机。</li>
<li>添加视频与音频通信。</li>
</ol>
<h2>首先来看看Demo:</h2>
<p><strong>Demo 操作:</strong></p>
<p>1. 输入任意名称，点击链接 （两台机器或者两个浏览器）<br />
2. 输入对方的peerId，点击呼叫<br />
3. 被呼叫方点击 &#8220;接受&#8221; 建立链接。<br />
4. 开始语音，视频，文字通讯.<br />
5. 挂机</p>
<p><strong>Demo地址:</strong></p>
<p><a href="http://flextheworld.com/flash/p2p/P2pPhoneDemo.html" target="_blank">http://flextheworld.com/flash/p2p/P2pPhoneDemo.html</a></p>
<p><a href="http://flextheworld.com/flash/p2p/P2pPhoneDemo.html" target="_blank"><span id="more-276"></span></a></p>
<p><strong>Demo截图:</strong></p>
<p><img class="alignnone size-full wp-image-279" title="e59bbee78987-1" src="http://www.flextheworld.com/wp-content/uploads/2009/01/e59bbee78987-1.jpg" alt="e59bbee78987-1" width="640" height="400" /></p>
<h2>新添加的代码</h2>
<p>首先是修改call() function, 根据不同的label执行不同的事件，如果callYou.label是 &#8220;接受&#8221;，执行accpetHandle()与呼叫者建立链接，如果是&#8221;挂断&#8221;，那么执行hangup()挂断双方的通讯，如果是其他(也就是&#8221;呼叫&#8221;)，则执行后面的内容。</p>
<p>呼叫时调用publishVide和publishAudio将视频与音频附加到outgoingStream发送。在onConnectSuccesss事件中播放被呼叫者返回的视频和音频。监听onHangup事件来控制挂断。呼叫时将“呼叫”改为“挂断”。</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('p276code6'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2766"><td class="code" id="p276code6"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//呼叫对方的方法，现在是呼叫者角色</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">call</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>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>callYou<span style="color: #000066; font-weight: bold;">.</span>label == <span style="color: #990000;">&quot;接受&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
accpetHandle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
callYou<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;挂断&quot;</span>
<span style="color: #0033ff; font-weight: bold;">return</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: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>callYou<span style="color: #000066; font-weight: bold;">.</span>label == <span style="color: #990000;">&quot;挂断&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onHangup&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>hangup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">...............</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//发送视频</span>
publishVideo<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>
publishAudio<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">..........</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//监听onConnectSuccess事件，确定链接成功</span>
i<span style="color: #000066; font-weight: bold;">.</span>onConnectSuccess = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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;">&#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: #004993;">info</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><span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;链接成功n&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
sendMessageBtn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">receiveAudio</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>
incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">receiveAudio</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>
remoteVideo = <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>
remoteVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">160</span><span style="color: #000066; font-weight: bold;">;</span>
remoteVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">120</span><span style="color: #000066; font-weight: bold;">;</span>
remoteVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachNetStream</span><span style="color: #000000;">&#40;</span>incomingStream<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
remoteVideoDisplay<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>remoteVideo<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
sendMessageBtn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
i<span style="color: #000066; font-weight: bold;">.</span>onHangup = <span style="color: #339966; font-weight: bold;">function</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>
hangup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = i
&nbsp;
callYou<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;挂断&quot;</span></pre></td></tr></table></div>

<p>被呼叫者在监听到呼叫者的呼叫时不马上回应，只是提示被呼叫者 “正在被链接”，同时将“呼叫”改为“接受”, 监听onHangup事件</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('p276code7'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2767"><td class="code" id="p276code7"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> initSendStream<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>
&nbsp;
<span style="color: #000066; font-weight: bold;">..........</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//监听onPeerConnect事件</span>
<span style="color: #6699cc; font-weight: bold;">var</span> o<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>
o<span style="color: #000066; font-weight: bold;">.</span>onPeerConnect = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>subscriberStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a>
<span style="color: #000000;">&#123;</span>
<span style="color: #000066; font-weight: bold;">..........</span>
&nbsp;
incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">receiveAudio</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>
incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">receiveAudio</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>
<span style="color: #000066; font-weight: bold;">..........</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//监听onIncomingCall事件，用于确定链接成功</span>
i<span style="color: #000066; font-weight: bold;">.</span>onIncomingCall = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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;">&#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;">//显示链接成功后，对呼叫者发布我的信息流，名称为callee</span>
<span style="color: #004993;">info</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: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; 正在呼叫你n&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
callYou<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;接受&quot;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
i<span style="color: #000066; font-weight: bold;">.</span>onHangup = <span style="color: #339966; font-weight: bold;">function</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>
hangup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = i<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
myStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = o<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>点击“接受”后，开始向呼叫者发送信息流，包括视频与音频。同时播放呼叫者发送的视频与音频，最后发出onConnectSuccess事件</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('p276code8'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2768"><td class="code" id="p276code8"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//同意链接后，发送stream到呼叫端，包括音频，视频的发送。 同时播放呼叫端发出的视频，音频</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> accpetHandle<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>
outgoingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">.</span>DIRECT_CONNECTIONS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
outgoingStream<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> outgoingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">publish</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;callee&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//将视频，音频附加到outgoingStream</span>
publishAudio<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
publishVideo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//播放接受到的视频，音频</span>
incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">receiveAudio</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>
incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">receiveAudio</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>
remoteVideo = <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>
remoteVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">160</span><span style="color: #000066; font-weight: bold;">;</span>
remoteVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">120</span><span style="color: #000066; font-weight: bold;">;</span>
remoteVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachNetStream</span><span style="color: #000000;">&#40;</span>incomingStream<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
remoteVideoDisplay<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>remoteVideo<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//链接成功事件，呼叫端响应</span>
outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onConnectSuccess&quot;</span><span style="color: #000066; font-weight: bold;">,</span>userName<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
sendMessageBtn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>点击挂机后在上面提到的call()中执行hangup(), 同时发送onHangup事件，这样另一方也能挂断电话。挂机后将&#8221;挂机&#8221;再改为&#8221;呼叫&#8221;，允许下一次的呼叫和链接</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('p276code9'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2769"><td class="code" id="p276code9"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//挂断电话，清空所有stream，只保持于stratus的链接</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> hangup<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>incomingStream<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
incomingStream<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>
incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> incomingStreamHandler<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;">if</span> <span style="color: #000000;">&#40;</span>outgoingStream<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
outgoingStream<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>
outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> outgoingStreamHandler<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;">if</span> <span style="color: #000000;">&#40;</span>controlStream<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
controlStream<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>
controlStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> netStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
incomingStream = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
outgoingStream = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
controlStream = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>localVideo <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
localVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>remoteVideo <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
remoteVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #004993;">info</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>
callYou<span style="color: #000066; font-weight: bold;">.</span>label = <span style="color: #990000;">&quot;呼叫&quot;</span>
sendMessageBtn<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">enabled</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>publishVideo和publishAudio function</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('p276code10'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p27610"><td class="code" id="p276code10"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//发送视频</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> publishVideo<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: #6699cc; font-weight: bold;">var</span> cameras<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <a href="http://www.google.com/search?q=camera%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:camera.html"><span style="color: #004993;">Camera</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">names</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> camera<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=camera%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:camera.html"><span style="color: #004993;">Camera</span></a><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> findDefaultCamera<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a> = <span style="color: #0033ff; font-weight: bold;">false</span>
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>cameras <span style="color: #000066; font-weight: bold;">&amp;</span>amp<span style="color: #000066; font-weight: bold;">;&amp;</span>amp<span style="color: #000066; font-weight: bold;">;</span> cameras<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</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> j<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;">0</span><span style="color: #000066; font-weight: bold;">;</span> j<span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span>cameras<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> j<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>cameras<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #990000;">&quot;USB Video Class Video&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
camera = <a href="http://www.google.com/search?q=camera%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:camera.html"><span style="color: #004993;">Camera</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getCamera</span><span style="color: #000000;">&#40;</span>j<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span>camera<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
findDefaultCamera = <span style="color: #0033ff; font-weight: bold;">true</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>findDefaultCamera<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
camera = <a href="http://www.google.com/search?q=camera%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:camera.html"><span style="color: #004993;">Camera</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getCamera</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span>camera<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
camera<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setQuality</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">90</span><span style="color: #000000;">&#41;</span>
&nbsp;
localVideo = <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>
localVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">160</span><span style="color: #000066; font-weight: bold;">;</span>
localVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">120</span><span style="color: #000066; font-weight: bold;">;</span>
localVideo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span>camera<span style="color: #000000;">&#41;</span>
localVideoDisplay<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>localVideo<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>
<span style="color: #009900; font-style: italic;">//发送音频</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> publishAudio<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: #6699cc; font-weight: bold;">var</span> mics<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</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;">names</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>mics <span style="color: #000066; font-weight: bold;">&amp;</span>amp<span style="color: #000066; font-weight: bold;">;&amp;</span>amp<span style="color: #000066; font-weight: bold;">;</span> mics<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachAudio</span><span style="color: #000000;">&#40;</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><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getMicrophone</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: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h2>源文件下载 (装了一个类似论坛的回复才能下载的插件，试试)</h2>
<p><!--easy2hide start--><br />
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=5" title="Version1 downloaded 871 times" >P2pPhoneDemo3 (871)</a><br />
<!--easy2hide end--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/01/flex-stratus-phone-3.html/feed</wfw:commentRss>
		<slash:comments>347</slash:comments>
		</item>
		<item>
		<title>Flex 迷你教程 — 基于Stratus的P2P网络电话 (2)</title>
		<link>http://www.flextheworld.com/2009/01/flex-stratus-phone-2.html</link>
		<comments>http://www.flextheworld.com/2009/01/flex-stratus-phone-2.html#comments</comments>
		<pubDate>Sat, 10 Jan 2009 08:53:39 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[FMS]]></category>
		<category><![CDATA[Flex 迷你教程]]></category>
		<category><![CDATA[P2P]]></category>
		<category><![CDATA[Stratus]]></category>
		<category><![CDATA[网络电话]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=248</guid>
		<description><![CDATA[接上篇，这一讲里我告诉大家如何链接另一个flash客户端，并且发送文字信息，在下一讲中会引入更多的内容，比如，“是否接收对方呼叫”，“语音和视频的发送” 等等。
看这篇教程时一定要把自己分成“呼叫者”和“被呼叫者”两个身份来看，否者有可能会看得头晕，呵呵。现在我们开始。
1. 首先了解一下我们会用到的变量, 这里要最主要的四个NetStream，他们的作用请看注释。


?View Code ACTIONSCRIPT3//链接Adobe stratus 服务器
private const StratusAddress:String = &#34;rtmfp://stratus.adobe.com&#34;;
&#160;
//Developer Key,如果没有请根据Flex 迷你教程 -- 基于Stratus的P2P网络电话 (1)中的提示申请
private const DeveloperKey:String = &#34;xxxxxx&#34;;
&#160;
//我们需要一个nectConnetion与stratus 服务器链接
private var netConnection:NetConnection;
&#160;
//用于对外发布自己的身份信息流
private var myStream:NetStream;
&#160;
//用于链接后对外发布自己的信息流，比如音频，视频，文字
private var outgoingStream:NetStream;
&#160;
//进入的信息流，这个流对应呼叫者的outgoingStream，用这个流尝试播放发布者发布的信息，比如音频，视频，文字
private var incomingStream:NetStream;
&#160;
//用于尝试播放被呼叫者的身份信息流myStream发送的信息，被呼叫者在发送自己的身份信息流时会监听呼叫者对myStream的播放请求
private var controlStream:NetStream;

2. 下面是主要用到的方法。
呼叫者的主要方法/事件触发顺序，
init()
netConnectionHandler() &#8212; case &#8220;NetConnection.Connect.Success&#8221;:
initSendStream();
call();
onConnectSuccess()
onIm()
被呼叫者主要方法／事件的调用触发顺序
init()
netConnectionHandler() &#8212; case &#8220;NetConnection.Connect.Success&#8221;:
initSendStream();
onPeerConnect();
onIncomingCall();
onIm();
3. Demo (请打开两个浏览器进行Demo) :
操作方法:

任意填写用户名，点击链接。
在另一个浏览器同样登陆。
用其中一个的peerid作为链接ID呼叫对方。
链接成功后可以信息聊天。


4. 源代码下载与主要方法代码，学习请看注释，写的很清楚
输入用户名，点击 “链接”时触发下面的代码

?View Code ACTIONSCRIPT3//链接 adobe stratus 服务器
private function init&#40;&#41;:void&#123;
&#160;
	if&#40;userName.text == &#34;&#34;&#41;
	&#123;
		Alert.show&#40;&#34;请输入任意用户名&#34;,&#34;错误&#34;&#41;
		return
	&#125;
	netConnection = new [...]]]></description>
			<content:encoded><![CDATA[<p>接上篇，这一讲里我告诉大家如何链接另一个flash客户端，并且发送文字信息，在下一讲中会引入更多的内容，比如，“是否接收对方呼叫”，“语音和视频的发送” 等等。</p>
<p>看这篇教程时一定要把自己分成“呼叫者”和“被呼叫者”两个身份来看，否者有可能会看得头晕，呵呵。现在我们开始。</p>
<h2>1. 首先了解一下我们会用到的变量, 这里要最主要的四个NetStream，他们的作用请看注释。</h2>
<p><span id="more-248"></span></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('p248code18'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24818"><td class="code" id="p248code18"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//链接Adobe stratus 服务器</span>
<span style="color: #0033ff; font-weight: bold;">private</span> const StratusAddress<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;rtmfp://stratus.adobe.com&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//Developer Key,如果没有请根据Flex 迷你教程 -- 基于Stratus的P2P网络电话 (1)中的提示申请</span>
<span style="color: #0033ff; font-weight: bold;">private</span> const DeveloperKey<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;xxxxxx&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//我们需要一个nectConnetion与stratus 服务器链接</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> netConnection<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//用于对外发布自己的身份信息流</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> myStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//用于链接后对外发布自己的信息流，比如音频，视频，文字</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> outgoingStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//进入的信息流，这个流对应呼叫者的outgoingStream，用这个流尝试播放发布者发布的信息，比如音频，视频，文字</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> incomingStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//用于尝试播放被呼叫者的身份信息流myStream发送的信息，被呼叫者在发送自己的身份信息流时会监听呼叫者对myStream的播放请求</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> controlStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<h2>2. 下面是主要用到的方法。</h2>
<h3>呼叫者的主要方法/事件触发顺序，</h3>
<p>init()<br />
netConnectionHandler() &#8212; case &#8220;NetConnection.Connect.Success&#8221;:<br />
initSendStream();<br />
call();<br />
onConnectSuccess()<br />
onIm()</p>
<h3>被呼叫者主要方法／事件的调用触发顺序</h3>
<p>init()<br />
netConnectionHandler() &#8212; case &#8220;NetConnection.Connect.Success&#8221;:<br />
initSendStream();<br />
onPeerConnect();<br />
onIncomingCall();<br />
onIm();</p>
<h2>3. Demo (请打开两个浏览器进行Demo) :</h2>
<h3>操作方法:</h3>
<ol>
<li>任意填写用户名，点击链接。</li>
<li>在另一个浏览器同样登陆。</li>
<li>用其中一个的peerid作为链接ID呼叫对方。</li>
<li>链接成功后可以信息聊天。</li>
</ol>
<p><object width="520" height="516" data="http://www.flextheworld.com/flash/P2pPhoneDemo.swf" type="application/x-shockwave-flash"><param name="src" value="http://www.flextheworld.com/flash/P2pPhoneDemo.swf" /></object></p>
<h2>4. 源代码下载与主要方法代码，学习请看注释，写的很清楚</h2>
<h3>输入用户名，点击 “链接”时触发下面的代码</h3>

<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('p248code19'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24819"><td class="code" id="p248code19"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//链接 adobe stratus 服务器</span>
<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>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>userName<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> == <span style="color: #990000;">&quot;&quot;</span><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><span style="color: #990000;">&quot;错误&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0033ff; font-weight: bold;">return</span>
	<span style="color: #000000;">&#125;</span>
	netConnection = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	netConnection<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> netConnectionHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	netConnection<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connect</span><span style="color: #000000;">&#40;</span>StratusAddress <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;/&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> DeveloperKey<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//服务器地址里需要开发者Key</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>与stratus链接成功后在case &#8220;NetConnection.Connect.Success&#8221;里调用下面的方法</h3>

<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('p248code20'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24820"><td class="code" id="p248code20"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> initSendStream<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>
&nbsp;
	<span style="color: #009900; font-style: italic;">//这三行表示我对外发布一个名称为netConnection.nearID的流，呼叫者通过我的nearID与我链接后，如果播放</span>
	<span style="color: #009900; font-style: italic;">//这个名称为netConnection.nearID的流，会出发onPeerConnect事件，这样我就知道有人链接我</span>
	myStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">.</span>DIRECT_CONNECTIONS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	myStream<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> netStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	myStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">publish</span><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">.</span>nearID<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//监听onPeerConnect事件</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> o<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>
	o<span style="color: #000066; font-weight: bold;">.</span>onPeerConnect = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>subscriberStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #009900; font-style: italic;">//当我收到呼叫者的链接请求后，尝试播放呼叫者的流名为&quot;caller&quot;的流，farID代表呼叫者的唯一ID，也就是前面提到的nearID</span>
		<span style="color: #009900; font-style: italic;">//我通过farID找到呼叫者</span>
	    incomingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span>subscriberStream<span style="color: #000066; font-weight: bold;">.</span>farID<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        incomingStream<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> incomingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        incomingStream<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;caller&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        <span style="color: #009900; font-style: italic;">//监听onIm事件，用于收取文字信息</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=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: #000066; font-weight: bold;">;</span>
        i<span style="color: #000066; font-weight: bold;">.</span>onIm = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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: #000066; font-weight: bold;">,</span> <span style="color: #004993;">value</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;">&#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: #004993;">info</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: #004993;">name</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: #004993;">value</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: #009900; font-style: italic;">//监听onIncomingCall事件，用于确定链接成功</span>
        i<span style="color: #000066; font-weight: bold;">.</span>onIncomingCall = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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;">&#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;">//显示链接成功后，对呼叫者发布我的信息流，名称为callee</span>
            <span style="color: #004993;">info</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: #004993;">name</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>
            outgoingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">.</span>DIRECT_CONNECTIONS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	        outgoingStream<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> outgoingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">publish</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;callee&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onConnectSuccess&quot;</span><span style="color: #000066; font-weight: bold;">,</span>userName<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        <span style="color: #000000;">&#125;</span>
        incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = i<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	myStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = o<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>呼叫者输入对方Peerid，点击呼叫后执行下面的代码</h3>

<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('p248code21'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24821"><td class="code" id="p248code21"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">call</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>
&nbsp;
    <span style="color: #009900; font-style: italic;">//通过对方的peerId链接被呼叫者，播放对方的身份信息流</span>
    controlStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span>peerId<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    controlStream<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> netStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    controlStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span>peerId<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//同时对外发布呼叫者的信息流</span>
    outgoingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">.</span>DIRECT_CONNECTIONS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    outgoingStream<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> outgoingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">publish</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;caller&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//尝试播放被呼叫者的信息流</span>
    incomingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> peerId<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    incomingStream<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> incomingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    incomingStream<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;callee&quot;</span><span style="color: #000000;">&#41;</span><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;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;正在呼叫，请稍候...... <span style="">\n</span><span style="">\n</span>&quot;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//监听信息发布事件</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=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: #000066; font-weight: bold;">;</span>
    i<span style="color: #000066; font-weight: bold;">.</span>onIm = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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: #000066; font-weight: bold;">,</span> <span style="color: #004993;">value</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;">&#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: #004993;">info</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: #004993;">name</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: #004993;">value</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: #009900; font-style: italic;">//监听onConnectSuccess事件，确定链接成功</span>
     i<span style="color: #000066; font-weight: bold;">.</span>onConnectSuccess = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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;">&#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: #004993;">info</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><span style="color: #004993;">name</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> 
&nbsp;
    incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = i
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>被呼叫者在收到呼叫时执行</h3>

<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('p248code22'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24822"><td class="code" id="p248code22"><pre class="actionscript3" style="font-family:monospace;">o<span style="color: #000066; font-weight: bold;">.</span>onPeerConnect = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>subscriberStream<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a>
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900; font-style: italic;">//当我收到呼叫者的链接请求后，尝试播放呼叫者的流名为&quot;caller&quot;的流，farID代表呼叫者的唯一ID，也就是前面提到的nearID</span>
	<span style="color: #009900; font-style: italic;">//我通过farID找到呼叫者</span>
    incomingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span>subscriberStream<span style="color: #000066; font-weight: bold;">.</span>farID<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    incomingStream<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> incomingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    incomingStream<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;caller&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #009900; font-style: italic;">//监听onIm事件，用于收取文字信息</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=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: #000066; font-weight: bold;">;</span>
    i<span style="color: #000066; font-weight: bold;">.</span>onIm = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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: #000066; font-weight: bold;">,</span> <span style="color: #004993;">value</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;">&#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: #004993;">info</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: #004993;">name</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: #004993;">value</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: #009900; font-style: italic;">//监听onIncomingCall事件，用于确定链接成功</span>
    i<span style="color: #000066; font-weight: bold;">.</span>onIncomingCall = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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;">&#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;">//显示链接成功后，对呼叫者发布我的信息流，名称为callee</span>
        <span style="color: #004993;">info</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: #004993;">name</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>
        outgoingStream = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000000;">&#40;</span>netConnection<span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=netstream%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstream.html"><span style="color: #004993;">NetStream</span></a><span style="color: #000066; font-weight: bold;">.</span>DIRECT_CONNECTIONS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        outgoingStream<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=netstatusevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netstatusevent.html"><span style="color: #004993;">NetStatusEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NET_STATUS</span><span style="color: #000066; font-weight: bold;">,</span> outgoingStreamHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">publish</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;callee&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onConnectSuccess&quot;</span><span style="color: #000066; font-weight: bold;">,</span>userName<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #000000;">&#125;</span>
    incomingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">client</span> = i<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h3>呼叫者与被呼叫者链接成功后执行</h3>

<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('p248code23'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24823"><td class="code" id="p248code23"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//监听onConnectSuccess事件，确定链接成功</span>
i<span style="color: #000066; font-weight: bold;">.</span>onConnectSuccess = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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;">&#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: #004993;">info</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><span style="color: #004993;">name</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></pre></td></tr></table></div>

<h3>发送信息与接收信息代码</h3>

<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('p248code24'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24824"><td class="code" id="p248code24"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//用outgoingStream对外发布信息流</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">send</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: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= userName<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> <span style="color: #004993;">message</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;<span style="">\n</span>&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
    outgoingStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onIm&quot;</span><span style="color: #000066; font-weight: bold;">,</span>userName<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: #004993;">message</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//监听信息发布事件</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=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: #000066; font-weight: bold;">;</span>
i<span style="color: #000066; font-weight: bold;">.</span>onIm = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">name</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: #000066; font-weight: bold;">,</span> <span style="color: #004993;">value</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;">&#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: #004993;">info</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: #004993;">name</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: #004993;">value</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></pre></td></tr></table></div>

<h2>源代码</h2>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=4" title="Version0.5 downloaded 1387 times" >P2PhoneDemo1 (1387)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/01/flex-stratus-phone-2.html/feed</wfw:commentRss>
		<slash:comments>108</slash:comments>
		</item>
		<item>
		<title>FMS (Flash Media Server) 实例集</title>
		<link>http://www.flextheworld.com/2009/01/flash-media-interactive-server-feature-explorer.html</link>
		<comments>http://www.flextheworld.com/2009/01/flash-media-interactive-server-feature-explorer.html#comments</comments>
		<pubDate>Sat, 03 Jan 2009 09:03:47 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[FMS]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=169</guid>
		<description><![CDATA[原文标题：Using the Flash Media Interactive Server Feature Explorer
相信大家对Flex3 component explore以及Flex style explore已经不陌生了，他们对我们了解Flex控件以及如何设计样式有很大的帮助，现在(2008/7/21) Adobe又放出了 Flash Media Interactive Server Feature Explore，这使得我们学习Flex + FMS比原来又容易了太多, 还不知道FMS是干什么的？看看下面  
以下内容翻译自：http://www.adobe.com/devnet/flashmediaserver/articles/fmis_feature_explorer.html
FMIS server Feature Explorer 是用Adobe AIR开发的跨平台的桌面程序，它能帮助你探索 Flash以及AIR基于FMIS3的丰富且极具吸引力的应用。FMIS server Feature Explorer有超过30个的流媒体和多方式交流 (文字，视频交流)的例子。包括了基本的服务器链接实例，复杂的视频流，以及用户验证，你也可以从中学到如何开发视频信息以及网络电话。
安装好Feature Explorer的AIR端，下载服务器资源（下面的链接）并部属在免费的Flash Media 		      Development Server上。每个例子都有源码 (MXML, as3.0, 以及服务器AS代码)


如何安装Flash Media 		    Interactive Server Feature [...]]]></description>
			<content:encoded><![CDATA[<h3>原文标题：Using the Flash Media Interactive Server Feature Explorer</h3>
<p>相信大家对Flex3 component explore以及Flex style explore已经不陌生了，他们对我们了解Flex控件以及如何设计样式有很大的帮助，现在(2008/7/21) Adobe又放出了 Flash Media Interactive Server Feature Explore，这使得我们学习Flex + FMS比原来又容易了太多, 还不知道FMS是干什么的？看看下面 <img src='http://www.flextheworld.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<address><span style="color: #993300;">以下内容翻译自：<a href="http://www.adobe.com/devnet/flashmediaserver/articles/fmis_feature_explorer.html">http://www.adobe.com/devnet/flashmediaserver/articles/fmis_feature_explorer.html</a></span></address>
<p>FMIS server Feature Explorer 是用Adobe AIR开发的跨平台的桌面程序，它能帮助你探索 Flash以及AIR基于FMIS3的丰富且极具吸引力的应用。FMIS server Feature Explorer有超过30个的流媒体和多方式交流 (文字，视频交流)的例子。包括了基本的服务器链接实例，复杂的视频流，以及用户验证，你也可以从中学到如何开发视频信息以及网络电话。</p>
<p>安装好Feature Explorer的AIR端，下载服务器资源（下面的链接）并部属在免费的<a href="http://www.adobe.com/go/tryflashmediaserver">Flash Media 		      Development Server</a>上。每个例子都有源码 (MXML, as3.0, 以及服务器AS代码)</p>
<address><span style="color: #888888;"><span id="more-169"></span><br />
</span></address>
<address>如何安装Flash Media 		    Interactive Server Feature Explorer:</address>
<address> </address>
<address> </address>
<address> </address>
<ol>
<li>下载并安装Flash Media Development Server 3 或者               Flash Media Interactive Server 3. (不要装Flash               Media Streaming Server 3)</li>
<li>下载并解压服务器端代码和视频文件（下面有下载）到你FMIS安装目录的/applications文件夹</li>
<li>安装 Flash Media Interactive Server Feature 		      Explorer的AIR端。</li>
<li>启动 Flash Media Interactive Server Feature 		      Explorer</li>
<li>点击顶部的Configure Services</li>
<li>输入FMIS地址，管理员信息。</li>
<li>测试多服务器的例子，输入第二台服务器的地址。</li>
</ol>
<p style="text-align: center;"><img class="size-full wp-image-172 aligncenter" title="e59bbee78987-3" src="http://www.flextheworld.com/wp-content/uploads/2009/01/e59bbee78987-3.png" alt="e59bbee78987-3" width="418" height="343" /></p>
<h2>相关资源下载</h2>
<p><strong>Flash Media Interactive Server Feature Explorer</strong></p>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=1" title="Version1.0 downloaded 550 times" >fms_explorer.air (550)</a>
<p><strong>服务器端代码以及素材</strong></p>
<p><a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=2" title="Version1.0 downloaded 3226 times" >fms_explorer_samples.zip (3226)</a> (ZIP, 55MB)</p>
<p><a href="http://www.adobe.com/go/tryflash_media_server" target="_blank"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/01/flash-media-interactive-server-feature-explorer.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
