<?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>PawaStation 能猫环岛 &#187; e4x</title>
	<atom:link href="http://blog.pawa.ca/tag/e4x/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pawa.ca</link>
	<description>An Apple a Day Keeps the Doctor Away</description>
	<lastBuildDate>Sun, 08 Mar 2009 04:39:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>E4X 的另类应用</title>
		<link>http://blog.pawa.ca/2006/09/12/e4x-in-as3/</link>
		<comments>http://blog.pawa.ca/2006/09/12/e4x-in-as3/#comments</comments>
		<pubDate>Tue, 12 Sep 2006 06:32:01 +0000</pubDate>
		<dc:creator>pawaca</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[e4x]]></category>

		<guid isPermaLink="false">http://blog.pawa.ca/?p=63</guid>
		<description><![CDATA[一直以来我们在 actionscript 中内嵌大段的多行文本时必须在每一号加上引号，然后再在结尾写加号。问题是一天三遍的写，太麻烦了。。。一直也没见过什么解决办法（除非写个外部文件载入，不过那个不爽，请忽略）。直到有一天。。。也就是昨天晚上，我一不小心想到了一个解决方案，大家请看： 12345678910111213var t:String=plain&#40;&#41;&#40;&#60;!-- The Flash Player API classes are in the flash.* packages. The Flash Player API refers to all packages, classes, functions, properties, constants, events, and errors that are in the flash package. They are unique to Flash Player, as opposed to the top-level classes, such as Date, Math, and XML, or [...]]]></description>
			<content:encoded><![CDATA[<p>一直以来我们在 actionscript 中内嵌大段的多行文本时必须在每一号加上引号，然后再在结尾写加号。问题是一天三遍的写，太麻烦了。。。一直也没见过什么解决办法（除非写个外部文件载入，不过那个不爽，请忽略）。直到有一天。。。也就是昨天晚上，我一不小心想到了一个解决方案，大家请看：</p>

<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> t<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>=plain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">&lt;!--</span><br />
The Flash Player API classes are <span style="color: #0033ff; font-weight: bold;">in</span> the flash<span style="color: #000066; font-weight: bold;">.*</span> packages<span style="color: #000066; font-weight: bold;">.</span><br />
The Flash Player API refers to all packages<span style="color: #000066; font-weight: bold;">,</span> classes<span style="color: #000066; font-weight: bold;">,</span> functions<span style="color: #000066; font-weight: bold;">,</span><br />
properties<span style="color: #000066; font-weight: bold;">,</span> constants<span style="color: #000066; font-weight: bold;">,</span> events<span style="color: #000066; font-weight: bold;">,</span> and errors that are <span style="color: #0033ff; font-weight: bold;">in</span> the flash <span style="color: #9900cc; font-weight: bold;">package</span><span style="color: #000066; font-weight: bold;">.</span><br />
They are unique to Flash Player<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">as</span> opposed to the top<span style="color: #000066; font-weight: bold;">-</span><span style="color: #004993;">level</span> classes<span style="color: #000066; font-weight: bold;">,</span><br />
such <span style="color: #0033ff; font-weight: bold;">as</span> <a href="http://www.google.com/search?q=date%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:date.html"><span style="color: #004993;">Date</span></a><span style="color: #000066; font-weight: bold;">,</span> <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">,</span> and <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: #000066; font-weight: bold;">,</span> or the <span style="color: #004993;">language</span> <span style="color: #004993;">elements</span><span style="color: #000066; font-weight: bold;">,</span> which are based<br />
on ECMAScript<span style="color: #000066; font-weight: bold;">.</span> The Flash Player API <span style="color: #004993;">contains</span> features that you expect<br />
to find <span style="color: #0033ff; font-weight: bold;">in</span> object<span style="color: #000066; font-weight: bold;">-</span>oriented programming languages<span style="color: #000066; font-weight: bold;">,</span> such <span style="color: #0033ff; font-weight: bold;">as</span> the<br />
<span style="color: #004993;">flash.geom</span> <span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #0033ff; font-weight: bold;">for</span> geometry classes<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">as</span> well <span style="color: #0033ff; font-weight: bold;">as</span> features specific<br />
to the needs of rich Internet applications<span style="color: #000066; font-weight: bold;">,</span> such <span style="color: #0033ff; font-weight: bold;">as</span> the <span style="color: #004993;">flash.filters</span><br />
<span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #0033ff; font-weight: bold;">for</span> expressiveness and the <span style="color: #004993;">flash.net</span> <span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #0033ff; font-weight: bold;">for</span> handling <span style="color: #004993;">data</span><br />
transmission to and from a server<span style="color: #000066; font-weight: bold;">.</span><br />
<span style="color: #000066; font-weight: bold;">--&gt;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>

<p>这个 plain 方法把代码中的一整段文本复给 t 变量，而字符串本身不用加引号！关键点就在 <!-- --> 标识符，挖哈哈，这个 e4x 的应用还不错吧。</p>

<p>另外一个想到的应用是不用 Flex 的 embed 标签也可以内嵌图片等二进制元素到源码中，因为 Flex 的 embed 语法是不兼容 flash9 的，而且需要莫名其妙的引入 mx 包下的一些类。所以这个应用也是有一定用处地：</p>

<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">b</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>=plain<span style="color: #000000;">&#40;</span><span style="color: #009966; font-style: italic;">/W*/g</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">&lt;!--</span><br />
89504e470d0a1a0a0000000d49484452<br />
0000000e000000100803000000114abe<br />
080000000467414d410000afc837058a<br />
e90000001974455874536f6674776172<br />
650041646f626520496d616765526561<br />
647971c9653c0000000f504c5445ffff<br />
ffff0000cccccc9999990000003952e0<br />
8a000000314944415478da626046010c<br />
cc0c08c0c4423a9791118261b28c8c20<br />
1e4231988743165d2fb9ce6042022c0c<br />
2c280020c0006dc501097dfe85550000<br />
000049454e44ae426082<br />
<span style="color: #000066; font-weight: bold;">--&gt;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>

<p>至于这一大堆乱码是什么意思，大家意会吧。。。</p>

<p>plain 方法的具体实现就不说了，很简单。有兴趣的朋友可以 <a href="http://blog.pawa.ca/wp-content/uploads/2009/03/test_plain_text.zip">在这里下载源码和实例</a> 研究一蛤。</p>

<p>另外通过这个方法，我还发现了 as3 的编译器，以及 flex builder 2 的 as3 编辑器在词法分析上还是存在问题的。比如有时候我在 <!-- --> 之间加入一整段类/包定义，编译器居然报错了。。。而且编辑器也很勤劳的加上语法高亮什么的。。。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.pawa.ca/2006/09/12/e4x-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
