<?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; AIR 2.0</title>
	<atom:link href="http://www.flextheworld.com/tag/air-2-0/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>Adobe AIR 2 beta 2 放出</title>
		<link>http://www.flextheworld.com/2010/02/adobe-air-2-beta-2.html</link>
		<comments>http://www.flextheworld.com/2010/02/adobe-air-2-beta-2.html#comments</comments>
		<pubDate>Wed, 10 Feb 2010 01:34:46 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[新闻]]></category>
		<category><![CDATA[AIR 2.0]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=688</guid>
		<description><![CDATA[2010年的2月2日，Adobe发布了AIR 2 beta 2. 由于当前的一个项目需要操作到硬件，所以早早的使用的AIR 2 beta 1进行开发。不过也确实体验到了Beta 1 中Bug的厉害。
1. 在1.5 中运行很好的程序刚换上AIR 2并打包成exe后，立马在退出程序时导致windows爆出程序关闭异常。
2. 在1.5中运行得很好的数据库操作部分(transaction)，在AIR 2中出了莫名其妙的错误。找不到具体原因。只有暂时放弃它的transation, 改用了自己的代替。在正式版发布后再替换回来吧只有。
此次AIR 2 beta 2的更新包括
1. 打印增强。
2. TTL/SSL sokcets.
3. 等等
详细信息请看这里 http://labs.adobe.com/wiki/index.php/AIR_2:Release_Notes
]]></description>
			<content:encoded><![CDATA[<p>2010年的2月2日，Adobe发布了AIR 2 beta 2. 由于当前的一个项目需要操作到硬件，所以早早的使用的AIR 2 beta 1进行开发。不过也确实体验到了Beta 1 中Bug的厉害。</p>
<p>1. 在1.5 中运行很好的程序刚换上AIR 2并打包成exe后，立马在退出程序时导致windows爆出程序关闭异常。<br />
2. 在1.5中运行得很好的数据库操作部分(transaction)，在AIR 2中出了莫名其妙的错误。找不到具体原因。只有暂时放弃它的transation, 改用了自己的代替。在正式版发布后再替换回来吧只有。</p>
<p>此次AIR 2 beta 2的更新包括</p>
<p>1. 打印增强。<br />
2. TTL/SSL sokcets.<br />
3. 等等</p>
<p>详细信息请看这里 http://labs.adobe.com/wiki/index.php/AIR_2:Release_Notes</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2010/02/adobe-air-2-beta-2.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AIR 迷你教程 — 在AIR 2.0 程序中嵌入TOMCAT（NativeProcess 实例）</title>
		<link>http://www.flextheworld.com/2010/01/air-2-tomcat-nativeprocess.html</link>
		<comments>http://www.flextheworld.com/2010/01/air-2-tomcat-nativeprocess.html#comments</comments>
		<pubDate>Thu, 21 Jan 2010 06:04:05 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[AIR 迷你教程]]></category>
		<category><![CDATA[AIR 2.0]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=670</guid>
		<description><![CDATA[AIR 2.0 有很多令人期待和振奋的功能，使得AIR向成熟的桌面应用程序开发环境又进了一大步。上一篇文章里介绍了ServerSocket的用法，这篇教程中将向大家介绍NativeProcess，在AIR2.0中我们可以使用程序默认的打开方式直接打开一个外部的应用程序 (file.openWithDefaultApplication()) 或者 通过今天要讲的启动进程方式运行一个程序。
AIR与本地应用程序的交互是AIR 2.0的一个重要更新，这个功能的实现可以帮助我们做到在AIR 1.5时代很难完成的事情，比如我在项目中就需要操作一些硬件，但AIR不能直接操作端口，所以只能借助其他的小程序来实现，现在我们就可以很容易的操作这些小程序以达到操作硬件的目的，而Flex (AIR)与JAVA的结合很早就已经开始了，但由于早期AIR的局限性，想要把JAVA直接部署在客户端还是比较麻烦的事情，但是从AIR2.0开始我们不用担心了。现在我们用很简单的方式就可以在AIR程序中集成TOMCAT, 一次性的将后台与AIR部署到客户端。
程序的原版（Flash Builder 4版）同样是从http://coenraets.org/获得，有兴趣的朋友可以关注这个博客。我的例子仍然使用FLEX 3.
Demo过程

下载安装 AIR 2.0 beta runtime.
下载AIRAppWithEmbeddedTomcat..exe 或者 AIRAppWithEmbeddedTomcat.dmg (NativeProcess 必须在程序发布为相应平台的应用程序后才可以使用，发布的方法这里就不介绍了，可以参看http://help.adobe.com/en_US/FlashPlatform/develop/air/building_apps/WS789ea67d3e73a8b22388411123785d839c-8000.html)
安装运行AIRAppWithEmbeddedTomcat.exe, 修改JAVA_HOME，如果默认的路径不对
点击 &#8220;启动&#8221; 可以开启TOMCAT(端口是8080)。在JSP实例和RemoteObject实例中可以看见加载JSP页面和使用RemoteObject获取数据的测试。


控制台
 

JSP 加载测试

RemoteObject 测试

源代码

?View Code ACTIONSCRIPT3&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;!--www.flextheworld.com--&#62;
&#60;mx:WindowedApplication applicationComplete=&#34;init()&#34; xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; height=&#34;600&#34; width=&#34;800&#34; &#62;
	&#60;mx:Script&#62;
        &#60;!&#91;CDATA&#91;
            [...]]]></description>
			<content:encoded><![CDATA[<p>AIR 2.0 有很多令人期待和振奋的功能，使得AIR向成熟的桌面应用程序开发环境又进了一大步。上一篇文章里介绍了ServerSocket的用法，这篇教程中将向大家介绍NativeProcess，在AIR2.0中我们可以使用程序默认的打开方式直接打开一个外部的应用程序 (<span style="font-family: Monaco, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: normal; font-size: 11px; ">file.openWithDefaultApplication()<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; ">) 或者 通过今天要讲的启动进程方式运行一个程序。</span></span></p>
<p>AIR与本地应用程序的交互是AIR 2.0的一个重要更新，这个功能的实现可以帮助我们做到在AIR 1.5时代很难完成的事情，比如我在项目中就需要操作一些硬件，但AIR不能直接操作端口，所以只能借助其他的小程序来实现，现在我们就可以很容易的操作这些小程序以达到操作硬件的目的，而Flex (AIR)与JAVA的结合很早就已经开始了，但由于早期AIR的局限性，想要把JAVA直接部署在客户端还是比较麻烦的事情，但是从AIR2.0开始我们不用担心了。现在我们用很简单的方式就可以在AIR程序中集成TOMCAT, 一次性的将后台与AIR部署到客户端。</p>
<p>程序的原版（Flash Builder 4版）同样是从http://coenraets.org/获得，有兴趣的朋友可以关注这个博客。我的例子仍然使用FLEX 3.</p>
<p style="margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; padding: 0px; border: 0px initial initial;"><strong>Demo过程</strong></p>
<ol style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 20px; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-position: initial initial; padding: 0px; border: 0px initial initial;">
<li style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">下载安装 <a style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; color: #000000; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://labs.adobe.com/downloads/air2.html" target="_blank">AIR 2.0 beta runtime</a>.</li>
<li style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">下载AIRAppWithEmbeddedTomcat..exe 或者 AIRAppWithEmbeddedTomcat.dmg (NativeProcess 必须在程序发布为相应平台的应用程序后才可以使用，发布的方法这里就不介绍了，可以参看http://help.adobe.com/en_US/FlashPlatform/develop/air/building_apps/WS789ea67d3e73a8b22388411123785d839c-8000.html)</li>
<li style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">安装运行AIRAppWithEmbeddedTomcat.exe, 修改JAVA_HOME，如果默认的路径不对</li>
<li style="outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">点击 &#8220;启动&#8221; 可以开启TOMCAT(端口是8080)。在JSP实例和RemoteObject实例中可以看见加载JSP页面和使用RemoteObject获取数据的测试。</li>
</ol>
<p><span id="more-670"></span></p>
<p><strong>控制台</strong></p>
<p><strong> </strong></p>
<p><img class="alignnone size-full wp-image-672" title="a" src="http://www.flextheworld.com/wp-content/uploads/2010/01/a1.gif" alt="a" width="700" height="503" /></p>
<p><strong>JSP 加载测试</strong></p>
<p><strong><img class="alignnone size-full wp-image-673" title="b" src="http://www.flextheworld.com/wp-content/uploads/2010/01/b.gif" alt="b" width="693" height="499" /></strong></p>
<p><strong>RemoteObject 测试</strong></p>
<p><strong><img class="alignnone size-full wp-image-674" title="c" src="http://www.flextheworld.com/wp-content/uploads/2010/01/c.gif" alt="c" width="690" height="499" /></strong></p>
<p><strong>源代码</strong></p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p670code2'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6702"><td class="code" id="p670code2"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span>
<span style="color: #000066; font-weight: bold;">&lt;!--</span>www<span style="color: #000066; font-weight: bold;">.</span>flextheworld<span style="color: #000066; font-weight: bold;">.</span>com<span style="color: #000066; font-weight: bold;">--&gt;</span>
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>WindowedApplication applicationComplete=<span style="color: #990000;">&quot;init()&quot;</span> xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #990000;">&quot;vertical&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;600&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;800&quot;</span> <span style="color: #000066; font-weight: bold;">&gt;</span>
	<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span>
        <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
            <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>Alert<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
            <span style="color: #009900; font-style: italic;">//用于启动和停止Tomcat的进程</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> startTomcatProcess<span style="color: #000066; font-weight: bold;">:</span>NativeProcess<span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> stopTomcatProcess<span style="color: #000066; font-weight: bold;">:</span>NativeProcess<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> tomcatHomeDir<span style="color: #000066; font-weight: bold;">:</span>File<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>NativeProcess<span style="color: #000066; font-weight: bold;">.</span>isSupported<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: #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;">//如果tomcat不存在，重新复制到app store文件夹</span>
                tomcatHomeDir = File<span style="color: #000066; font-weight: bold;">.</span>applicationStorageDirectory<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;tomcat&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>tomcatHomeDir<span style="color: #000066; font-weight: bold;">.</span>exists<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> tomcatOriginalDir<span style="color: #000066; font-weight: bold;">:</span>File = File<span style="color: #000066; font-weight: bold;">.</span>applicationDirectory<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;tomcat&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Copying tomcat to appStorageDirectory...&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    tomcatOriginalDir<span style="color: #000066; font-weight: bold;">.</span>copyTo<span style="color: #000000;">&#40;</span>tomcatHomeDir<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> f<span style="color: #000066; font-weight: bold;">:</span>File<span style="color: #000066; font-weight: bold;">;</span>
                    f<span style="color: #000066; font-weight: bold;">.</span>openWithDefaultApplication<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
                tomcatHome<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = tomcatHomeDir<span style="color: #000066; font-weight: bold;">.</span>nativePath<span style="color: #000066; font-weight: bold;">;</span>             
&nbsp;
                <span style="color: #009900; font-style: italic;">// 读取保存的配置（第一次运行以后生成）</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> xml<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a> = readConfig<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>xml <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>
                    javaHome<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = xml<span style="color: #000066; font-weight: bold;">.</span>javaHome<span style="color: #000066; font-weight: bold;">;</span>
                    <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: #009900; font-style: italic;">// 如果第一次使用，设置默认Path</span>
                <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=capabilities%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:capabilities.html"><span style="color: #004993;">Capabilities</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">os</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toLowerCase</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">indexOf</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;win&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #009900; font-style: italic;">// 默认的JAVA_HOME (windows)</span>
                    javaHome<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;C:<span style="">\\</span>Program Files<span style="">\\</span>Java<span style="">\\</span>jdk1.6.0&quot;</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><a href="http://www.google.com/search?q=capabilities%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:capabilities.html"><span style="color: #004993;">Capabilities</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">os</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toLowerCase</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">indexOf</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;mac&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #009900; font-style: italic;">// 默认的JAVA_HOME (Mac)</span>
                    javaHome<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> startTomcat<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;">// 将本次的JAVA_HOMR写入配置文件</span>
                writeConfig<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
                <span style="color: #004993;">log</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Starting Tomcat...&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> File<span style="color: #000066; font-weight: bold;">.</span>lineEnding<span style="color: #000066; font-weight: bold;">;</span>
                startTomcatProcess = <span style="color: #0033ff; font-weight: bold;">new</span> NativeProcess<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                execute<span style="color: #000000;">&#40;</span>startTomcatProcess<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;start&quot;</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: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> stopTomcat<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;">log</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Stopping Tomcat...&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> File<span style="color: #000066; font-weight: bold;">.</span>lineEnding<span style="color: #000066; font-weight: bold;">;</span>
                stopTomcatProcess = <span style="color: #0033ff; font-weight: bold;">new</span> NativeProcess<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                execute<span style="color: #000000;">&#40;</span>startTomcatProcess<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;stop&quot;</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: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> execute<span style="color: #000000;">&#40;</span>process<span style="color: #000066; font-weight: bold;">:</span>NativeProcess<span style="color: #000066; font-weight: bold;">,</span> arg<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;">// 先获取JVM</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> file<span style="color: #000066; font-weight: bold;">:</span>File = <span style="color: #0033ff; font-weight: bold;">new</span> File<span style="color: #000000;">&#40;</span>javaHome<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: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=capabilities%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:capabilities.html"><span style="color: #004993;">Capabilities</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">os</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toLowerCase</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">indexOf</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;win&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    file = file<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;bin/javaw.exe&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0033ff; font-weight: bold;">else</span>
                <span style="color: #000000;">&#123;</span>
                    file = file<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Home/bin/java&quot;</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;">// 启动TOMCAT</span>
                <span style="color: #0033ff; font-weight: bold;">try</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> nativeProcessStartupInfo<span style="color: #000066; font-weight: bold;">:</span>NativeProcessStartupInfo = <span style="color: #0033ff; font-weight: bold;">new</span> NativeProcessStartupInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    nativeProcessStartupInfo<span style="color: #000066; font-weight: bold;">.</span>executable = file<span style="color: #000066; font-weight: bold;">;</span>
                    nativeProcessStartupInfo<span style="color: #000066; font-weight: bold;">.</span>workingDirectory = tomcatHomeDir<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;bin&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> processArgs<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>String<span style="color: #000066; font-weight: bold;">&gt;</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>String<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    processArgs<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;-Dcatalina.home=&quot;</span><span style="color: #000066; font-weight: bold;">+</span>tomcatHomeDir<span style="color: #000066; font-weight: bold;">.</span>nativePath<span style="color: #000066; font-weight: bold;">;</span>
                    processArgs<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;-classpath&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                    processArgs<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#93;</span> = tomcatHomeDir<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;bin/bootstrap.jar&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>nativePath<span style="color: #000066; font-weight: bold;">;</span>
                    processArgs<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;org.apache.catalina.startup.Bootstrap&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                    processArgs<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#93;</span> = arg<span style="color: #000066; font-weight: bold;">;</span>
                    nativeProcessStartupInfo<span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=arguments%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:arguments.html"><span style="color: #004993;">arguments</span></a> = processArgs<span style="color: #000066; font-weight: bold;">;</span>
                    startTomcatProcess = <span style="color: #0033ff; font-weight: bold;">new</span> NativeProcess<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    startTomcatProcess<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span>nativeProcessStartupInfo<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    startTomcatProcess<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000066; font-weight: bold;">.</span>STANDARD_OUTPUT_DATA<span style="color: #000066; font-weight: bold;">,</span>
                        outputDataHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    startTomcatProcess<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000066; font-weight: bold;">.</span>STANDARD_ERROR_DATA<span style="color: #000066; font-weight: bold;">,</span>
                        errorOutputDataHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0033ff; font-weight: bold;">catch</span> <span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=error%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:error.html"><span style="color: #004993;">Error</span></a><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">message</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;Error&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> outputDataHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> process<span style="color: #000066; font-weight: bold;">:</span>NativeProcess = event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span> <span style="color: #0033ff; font-weight: bold;">as</span> NativeProcess<span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">data</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> = process<span style="color: #000066; font-weight: bold;">.</span>standardOutput<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">readUTFBytes</span><span style="color: #000000;">&#40;</span>process<span style="color: #000066; font-weight: bold;">.</span>standardOutput<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesAvailable</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #004993;">log</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> errorOutputDataHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=progressevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:progressevent.html"><span style="color: #004993;">ProgressEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> process<span style="color: #000066; font-weight: bold;">:</span>NativeProcess = event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span> <span style="color: #0033ff; font-weight: bold;">as</span> NativeProcess<span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">data</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> = process<span style="color: #000066; font-weight: bold;">.</span>standardError<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">readUTFBytes</span><span style="color: #000000;">&#40;</span>startTomcatProcess<span style="color: #000066; font-weight: bold;">.</span>standardError<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesAvailable</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #004993;">log</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> readConfig<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> file<span style="color: #000066; font-weight: bold;">:</span>File = File<span style="color: #000066; font-weight: bold;">.</span>applicationStorageDirectory<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;config.xml&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>file<span style="color: #000066; font-weight: bold;">.</span>exists<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> fileStream<span style="color: #000066; font-weight: bold;">:</span>FileStream = <span style="color: #0033ff; font-weight: bold;">new</span> FileStream<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    fileStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">open</span><span style="color: #000000;">&#40;</span>file<span style="color: #000066; font-weight: bold;">,</span> FileMode<span style="color: #000066; font-weight: bold;">.</span>READ<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #6699cc; font-weight: bold;">var</span> xml<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a> = <a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a><span style="color: #000000;">&#40;</span>fileStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">readUTFBytes</span><span style="color: #000000;">&#40;</span>fileStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesAvailable</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    fileStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                    <span style="color: #0033ff; font-weight: bold;">return</span> xml<span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0033ff; font-weight: bold;">else</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> writeConfig<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> xml<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;">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;'</span> <span style="color: #000066; font-weight: bold;">+</span> File<span style="color: #000066; font-weight: bold;">.</span>lineEnding<span style="color: #000066; font-weight: bold;">;</span>
                xml <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&lt;config&gt;&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> File<span style="color: #000066; font-weight: bold;">.</span>lineEnding<span style="color: #000066; font-weight: bold;">;</span>
                xml <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&lt;javaHome&gt;&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> javaHome<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;&lt;/javaHome&gt;&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> File<span style="color: #000066; font-weight: bold;">.</span>lineEnding<span style="color: #000066; font-weight: bold;">;</span>
                xml <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&lt;tomcatHome&gt;&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> tomcatHome<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;&lt;/tomcatHome&gt;&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> File<span style="color: #000066; font-weight: bold;">.</span>lineEnding<span style="color: #000066; font-weight: bold;">;</span>
                xml <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&lt;/config&gt;&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> File<span style="color: #000066; font-weight: bold;">.</span>lineEnding<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
                <span style="color: #6699cc; font-weight: bold;">var</span> file<span style="color: #000066; font-weight: bold;">:</span>File = File<span style="color: #000066; font-weight: bold;">.</span>applicationStorageDirectory<span style="color: #000066; font-weight: bold;">.</span>resolvePath<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;config.xml&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> fileStream<span style="color: #000066; font-weight: bold;">:</span>FileStream = <span style="color: #0033ff; font-weight: bold;">new</span> FileStream<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                fileStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">open</span><span style="color: #000000;">&#40;</span>file<span style="color: #000066; font-weight: bold;">,</span> FileMode<span style="color: #000066; font-weight: bold;">.</span>WRITE<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                fileStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">writeUTFBytes</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                fileStream<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
        <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
    <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>RemoteObject id=<span style="color: #990000;">&quot;srv&quot;</span> destination=<span style="color: #990000;">&quot;contacts&quot;</span> endpoint=<span style="color: #990000;">&quot;http://localhost:8080/messagebroker/amf&quot;</span> <span style="color: #000066; font-weight: bold;">/&gt;</span>
    <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>TabNavigator <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
        <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>VBox <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span> label=<span style="color: #990000;">&quot;控制台&quot;</span> paddingLeft=<span style="color: #990000;">&quot;8&quot;</span> paddingRight=<span style="color: #990000;">&quot;8&quot;</span> paddingBottom=<span style="color: #990000;">&quot;8&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Form <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
                <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>FormItem label=<span style="color: #990000;">&quot;Java Home&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
                    <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>TextInput id=<span style="color: #990000;">&quot;javaHome&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
                <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>FormItem<span style="color: #000066; font-weight: bold;">&gt;</span>
                <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>FormItem label=<span style="color: #990000;">&quot;Tomcat Home (嵌入的TOMCAT)&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
                    <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>TextInput id=<span style="color: #990000;">&quot;tomcatHome&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">enabled</span>=<span style="color: #990000;">&quot;false&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
                <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>FormItem<span style="color: #000066; font-weight: bold;">&gt;</span>
            <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>Form<span style="color: #000066; font-weight: bold;">&gt;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>HBox<span style="color: #000066; font-weight: bold;">&gt;</span>
                <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;启动&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;startTomcat()&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
                <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;停止&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;stopTomcat()&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
                <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;清除信息&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;log.text=''&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>HBox<span style="color: #000066; font-weight: bold;">&gt;</span>
            <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>TextArea id=<span style="color: #990000;">&quot;log&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>VBox<span style="color: #000066; font-weight: bold;">&gt;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>VBox label=<span style="color: #990000;">&quot;嵌入的JSP实例&quot;</span> paddingLeft=<span style="color: #990000;">&quot;8&quot;</span> paddingRight=<span style="color: #990000;">&quot;8&quot;</span> paddingBottom=<span style="color: #990000;">&quot;8&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
            <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>HTML id=<span style="color: #990000;">&quot;html&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
            <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;读取JSP&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;html.location='http://localhost:8080'&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
        <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>VBox<span style="color: #000066; font-weight: bold;">&gt;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>VBox label=<span style="color: #990000;">&quot;嵌入的RemoteObject实例&quot;</span> paddingLeft=<span style="color: #990000;">&quot;8&quot;</span> paddingRight=<span style="color: #990000;">&quot;8&quot;</span> paddingBottom=<span style="color: #990000;">&quot;8&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
            <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>DataGrid <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;100%&quot;</span> dataProvider=<span style="color: #990000;">&quot;{srv.findAll.lastResult}&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
                <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>columns<span style="color: #000066; font-weight: bold;">&gt;</span>
                    <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>DataGridColumn dataField=<span style="color: #990000;">&quot;id&quot;</span> headerText=<span style="color: #990000;">&quot;Id&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
                    <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>DataGridColumn dataField=<span style="color: #990000;">&quot;firstName&quot;</span> headerText=<span style="color: #990000;">&quot;First Name&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
                    <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>DataGridColumn dataField=<span style="color: #990000;">&quot;lastName&quot;</span> headerText=<span style="color: #990000;">&quot;Last Name&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
                    <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>DataGridColumn dataField=<span style="color: #990000;">&quot;city&quot;</span> headerText=<span style="color: #990000;">&quot;City&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
                <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>columns<span style="color: #000066; font-weight: bold;">&gt;</span>
            <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>DataGrid<span style="color: #000066; font-weight: bold;">&gt;</span>
            <span style="color: #000066; font-weight: bold;">&lt;</span>mx<span style="color: #000066; font-weight: bold;">:</span>Button label=<span style="color: #990000;">&quot;获取数据&quot;</span> <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;srv.findAll()&quot;</span><span style="color: #000066; font-weight: bold;">/&gt;</span>
        <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>VBox<span style="color: #000066; font-weight: bold;">&gt;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>TabNavigator<span style="color: #000066; font-weight: bold;">&gt;</span>
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">:</span>WindowedApplication<span style="color: #000066; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p><strong>下载</strong></p>
<p><strong> </strong><br />
源代码: <a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=21" title=" downloaded 221 times" >AIRAppWithEmbeddedTomcat.zip (221)</a></p>
<p>windows demo: <a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=22" title=" downloaded 176 times" >AIRAppWithEmbeddedTomcat.exe (176)</a></p>
<p>Mac Demo: <a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=23" title=" downloaded 120 times" >AIRAppWithEmbeddedTomcat.dmg (120)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2010/01/air-2-tomcat-nativeprocess.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AIR 迷你教程 &#8212; 用AIR 2.0创建迷你Web服务器（ServerSocket 实例）</title>
		<link>http://www.flextheworld.com/2010/01/air-2-serversocket.html</link>
		<comments>http://www.flextheworld.com/2010/01/air-2-serversocket.html#comments</comments>
		<pubDate>Wed, 06 Jan 2010 07:33:34 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[AIR 迷你教程]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[AIR 2.0]]></category>

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

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

运行效果如下:

源代码

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

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

<p>下载:</p>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=19" title=" downloaded 310 times" >MIniAIRWebServer.air (310)</a>
<a class="downloadlink" href="http://www.flextheworld.com/wp-content/plugins/download-monitor/download.php?id=20" title=" downloaded 314 times" >MIniAIRWebServer.zip (314)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2010/01/air-2-serversocket.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Adobe 发布　Flash Player 10.1 以及AIR 2.0</title>
		<link>http://www.flextheworld.com/2009/11/adobe-fp10-air.html</link>
		<comments>http://www.flextheworld.com/2009/11/adobe-fp10-air.html#comments</comments>
		<pubDate>Wed, 18 Nov 2009 01:25:26 +0000</pubDate>
		<dc:creator>Kevin Luo</dc:creator>
				<category><![CDATA[新闻]]></category>
		<category><![CDATA[AIR 2.0]]></category>
		<category><![CDATA[flash player 10.1]]></category>

		<guid isPermaLink="false">http://www.flextheworld.com/?p=630</guid>
		<description><![CDATA[非常激动人心的消息，我还没仔细看内容，先给大家分享了。
原文:
http://www.techcrunch.com/2009/11/16/adobe-flash-player-10-1-air-2-0/?utm_source=feedburner&#38;utm_medium=email&#38;utm_campaign=Feed%3A+Techcrunch+%28TechCrunch%29
]]></description>
			<content:encoded><![CDATA[<p>非常激动人心的消息，我还没仔细看内容，先给大家分享了。</p>
<p>原文:</p>
<p>http://www.techcrunch.com/2009/11/16/adobe-flash-player-10-1-air-2-0/?utm_source=feedburner&amp;utm_medium=email&amp;utm_campaign=Feed%3A+Techcrunch+%28TechCrunch%29</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flextheworld.com/2009/11/adobe-fp10-air.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
