<?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>GOVO's Blog</title>
	<atom:link href="http://blog.guitarbean.com/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.guitarbean.com</link>
	<description>Front-end web developer——[to be a better man]</description>
	<lastBuildDate>Wed, 11 Aug 2010 17:18:42 +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>到底谁废了谁？</title>
		<link>http://blog.guitarbean.com/2010/08/what-was-ruined.html</link>
		<comments>http://blog.guitarbean.com/2010/08/what-was-ruined.html#comments</comments>
		<pubDate>Wed, 11 Aug 2010 17:11:18 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=635</guid>
		<description><![CDATA[　　最近在看村上春树的《1Q84》，但断断续续，我看书不快。关于《1Q84》，我一开始并不知道是本怎么样的说，或者是本全新的小说，又可能只是另一个《且听风吟》或《寻羊历险记》。 　　书很厚，字号小，开始不久就有对女人乳房和一夜情的描写，当然书里的其它惊奇也不少，而且比较有画面感，翻译不算坏，读起来还是比较舒服的。所以它一直放在我床头柜上，夜晚无眠或者双休刚醒之晨，拿起来读读也是个不错的消遣。我买这本书时，虽然豆瓣上书评很多，但网店对书的介绍很少，有的只是对村上的吹捧，对书内容的透露基本没有，所以我还能很好的保持了对书的好奇，希望能自己探索下去。 　　然而，有一件事让我完全失去了对书的兴趣——一个剧透党花半天时间用囫囵吞枣的方式把书翻完后，然后以大概情节还记得细节不知所云的开篇大肆发表对这本书是如何，网上是如何评价它的性质是怎样的见解，说得我头脑顿感嗡嗡作响，想拒绝，但又说不出口，最悲剧的是最后还说出了一个万众触目的人物最终命运！擦！完了，这本书废了。这一折腾，仿佛好像一把刀子在书上乱划，书页一片片被撕烂扒落，最后只剩下一个新净硬破书壳。我对这本书已经完全没有兴趣了，20多块钱就这样扔进大海。其实钱不算什么，最大的挫败是人的希望没了，诺大的一本书，什么精神文化寓言哲理小资矫情寂寞忧伤爱恨交加感怀身世全部泡汤了。看小说，无非就是在情节中追求意义的或寻找自我的过程。怀着未知，追求的过程最重要，意义与结果就算失望也可原谅。但这里有一个条件，那就是怀着未知。所谓的好奇的前提就是不了解。提前被解密，一切只不过是个渣，可以扫进垃圾筒已。探险，也真正只有自己亲身探过的旅程才有意义。即使我现在硬着头皮去读，我的心情也大为不同，我已经无法再像之前那样单纯的好奇，我必须抱着被人强加的旧有观念去读；即使我不相信，我也变得抱着对另外事物批判的角度去读，也就是说，一切已经完全脱离了书本之外，毫无意义。 　　然而，我突然萌发一个奇想：其实是这本书废了，还是我被废了，还是把我与这本书之间的某种联系给废了？这本书，如果送给别人看，你不做剧透，别人一样能读出个所以言。作者只是少了你一个读者，作者也不会为了你改写它。如果说我被废了，有这个可能，凭什么我要相信他人一句话？轻易的被人打扰，规律一乱，则无法继续向前，这与成熟稳重的要求相差甚远。但可惜人的记忆有时候是牢固得可怕，或者这就是一种观念，或者我上面说的关于读小说的意义就是一种固有观念而已。然而我不做文学研究，不会对修辞手法情节构造进行解剖。就算有这个打算，就像品茶那样，没有人会硬从一杯白开水里说出个上下等铁观音龙井了吧？是把我与书本之间的特定联系废了？我看这最有可能。就像谋事在人的说法，最终能否读完，也要看与书有没有缘分。这么一想，突然有种脑袋开窍的感觉，一缕清风，仿佛自己已经站在了得道高僧之份上。佛说机缘，一切随意，坦然，让心境宁静致远。原来佛在面对无奈的事情时，也只有最后这一招了。]]></description>
			<content:encoded><![CDATA[<p>　　最近在看村上春树的《1Q84》，但断断续续，我看书不快。关于《1Q84》，我一开始并不知道是本怎么样的说，或者是本全新的小说，又可能只是另一个《且听风吟》或《寻羊历险记》。</p>
<p>　　书很厚，字号小，开始不久就有对女人乳房和一夜情的描写，当然书里的其它惊奇也不少，而且比较有画面感，翻译不算坏，读起来还是比较舒服的。所以它一直放在我床头柜上，夜晚无眠或者双休刚醒之晨，拿起来读读也是个不错的消遣。我买这本书时，虽然豆瓣上书评很多，但网店对书的介绍很少，有的只是对村上的吹捧，对书内容的透露基本没有，所以我还能很好的保持了对书的好奇，希望能自己探索下去。</p>
<p>　　然而，有一件事让我完全失去了对书的兴趣——一个剧透党花半天时间用囫囵吞枣的方式把书翻完后，然后以大概情节还记得细节不知所云的开篇大肆发表对这本书是如何，网上是如何评价它的性质是怎样的见解，说得我头脑顿感嗡嗡作响，想拒绝，但又说不出口，最悲剧的是最后还说出了一个万众触目的人物最终命运！擦！完了，这本书废了。这一折腾，仿佛好像一把刀子在书上乱划，书页一片片被撕烂扒落，最后只剩下一个新净硬破书壳。我对这本书已经完全没有兴趣了，20多块钱就这样扔进大海。其实钱不算什么，最大的挫败是人的希望没了，诺大的一本书，什么精神文化寓言哲理小资矫情寂寞忧伤爱恨交加感怀身世全部泡汤了。看小说，无非就是在情节中追求意义的或寻找自我的过程。怀着未知，追求的过程最重要，意义与结果就算失望也可原谅。但这里有一个条件，那就是怀着未知。所谓的好奇的前提就是不了解。提前被解密，一切只不过是个渣，可以扫进垃圾筒已。探险，也真正只有自己亲身探过的旅程才有意义。即使我现在硬着头皮去读，我的心情也大为不同，我已经无法再像之前那样单纯的好奇，我必须抱着被人强加的旧有观念去读；即使我不相信，我也变得抱着对另外事物批判的角度去读，也就是说，一切已经完全脱离了书本之外，毫无意义。</p>
<p>　　然而，我突然萌发一个奇想：其实是这本书废了，还是我被废了，还是把我与这本书之间的某种联系给废了？这本书，如果送给别人看，你不做剧透，别人一样能读出个所以言。作者只是少了你一个读者，作者也不会为了你改写它。如果说我被废了，有这个可能，凭什么我要相信他人一句话？轻易的被人打扰，规律一乱，则无法继续向前，这与成熟稳重的要求相差甚远。但可惜人的记忆有时候是牢固得可怕，或者这就是一种观念，或者我上面说的关于读小说的意义就是一种固有观念而已。然而我不做文学研究，不会对修辞手法情节构造进行解剖。就算有这个打算，就像品茶那样，没有人会硬从一杯白开水里说出个上下等铁观音龙井了吧？是把我与书本之间的特定联系废了？我看这最有可能。就像谋事在人的说法，最终能否读完，也要看与书有没有缘分。这么一想，突然有种脑袋开窍的感觉，一缕清风，仿佛自己已经站在了得道高僧之份上。佛说机缘，一切随意，坦然，让心境宁静致远。原来佛在面对无奈的事情时，也只有最后这一招了。</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=635&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2010/08/what-was-ruined.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>马路惊魂</title>
		<link>http://blog.guitarbean.com/2010/07/road-cry.html</link>
		<comments>http://blog.guitarbean.com/2010/07/road-cry.html#comments</comments>
		<pubDate>Wed, 14 Jul 2010 17:47:16 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=629</guid>
		<description><![CDATA[　　加班至二十一点回家，以科韵路几个路口，等待过马路的行人居然不少。真杯具，现代人都干什么去了，这么晚还在路上，莫非都加班？不过在一众白领（工资白领）中，难得见到一家三口——两公婆与一个八、九岁的娃，我想，这众人中，就这家子最快乐了。 　　这里的每个马路口至少有两个方面的车流。现在是回头转向的机动车绿灯，通常要等好一会，左转机动车灯也绿了，等左转的车流过了，才轮到行人过斑马线。要是平时，回头的车很少，三条车道中只要看最左边的没车了就可以过了，但现在回头的车居然很多，我想占点小便宜也不行。无奈只有等，看风景，数时间，看对面马路的美女，看机动车灯由一条车流到两条车流变绿，再齐齐变黄，变红，然后回头看斑马线上的行人灯，也由红变绿。要说黄灯是危险的时候不为过，一辆辆车都在黄灯时加速，赶在红灯前冲刺。这可不是黄灯设计的本意啊。所以虽然斑马线绿灯了，行人也只有看看车都愿意停了，才马过马路。 　　对面马路的美女动了，一家三口也动了，随之迈步。其中小孩的动作最快，蹦跳着就要走到马路中间，突然一辆一层楼高土黄色的泥头车高速飞过来，我一惊，马上停步，正想往后蹬的同时看见那小孩就要被撞上。不好，我想上去拉，双脚想改为向前蹬，但起码有５步远，来不及了，脚已不听使唤，停住了！脚虽然没有动，身体还是微微前倾，伸手想去拉。没用！根本就够不着，手在空中，更多的像是在指挥。我力不能及，听天由命吧！何止是我？刹那间，几乎同时的，我马路这边的人包括我都在大呼：“嘿，小心！” 　　“嗡~”泥头车的声音由远及近，仰面压来—— 　　就在这时，小孩突然停住了，他退后了一步！ 　　与此同时，泥头车微微往右一侧！ 　　就这样，在双方的一个轻微避让下，泥头车与小孩几乎是相隔不到30公分的距离呼啸而过，从右到左地！ 　　紧接着，泥头车车身还突然啪哒的一声翠响，然后一些玻璃落地的声音响起。原来是小孩的大人很愤怒的边骂边向泥头车扔了个东西。 　　泥头车稍稍慢了一下，似乎想停下来查看，但我们这群行人似乎都同时看过去，想打架，太好了，我好久没打过架了，正好想发泄一下呢。然而可惜，泥头车还是扬长而去，瞬间消失在路灯与混乱的黑夜中。 　　好险啊！ 　　现在想起那一刹那，危险极了，原来我是那么冲动，居然想冲出去拉！我晕，我想如果我真的这么做了，我就已经挂了，这不是死神来了么？ 　　马路如杀手啊。 　　我看到很多人都贪方便，走捷径，不走行斑马线爱走内弯，认为内弯安全，还认为是多高明，有胆色，有气概。其实不知多丑陋。这是一种小农意识，贪小便宜，为了一点东西，拼了命去做。太不值得了。把自己的性命交给一些毫不认识的人，多愚昧。为了赶几分钟，省几步脚力，却赌上自己的命，这投入产出比太小了，即使胜利，所得也不过是生命中相比与九牛一毛的蝇头小利，不费吹灰之力就可打发走的时间，以及不花分文就可储存起来的体力，一时之快，却是代价惨重。 　　如果你说我没胆色？错了，我的胆色不会用在愚蠢的地方，我会考虑投入产出。如果拿我的性命去赌，能换来让我满意的金钱，更有甚者是比生命更为之华丽的收获，我会赌上一吧。这个时候，你会吗？我怕你会不敢，你甚至还会退而求其次，心想：我还是每天赚点蝇头小利，日子得过且过吧。 　　贪一时之快，是大众人的心里，包括我在内，所以无论如何，我都会强忍，练耐性也好，总之在众人认为好而我又不屑的，我会告诉自己：不随波逐流，就要耐得住寂寞。 　　有时候三五狗友，劝赌劝酒，三缺一，赌上一次嘛，没关系的。事实上，当别人想劝你做一件事时，再大的关系，都会说成没关系，通过安抚，或激将之法，让你参与其中，多数人都会动容。过后你或后悔莫及，或上瘾。其实看狗友与挚友的分别，就在当他在干自己认为不良的事时，有没有把你拉进水的欲望。 　　话题似乎扯远了，但像国人对交通规则的遵守方面，其实都是与日常人们的相互影响相互榜样离不开的。想想，如果你有开过车，你会很怕行人。其实，当作为行人的你，也要为司机的心里想想，万一那个路人突然冲出来怎么办？行人是弱势群体，国家制定的保护行人的交通规则正是体现了人文情怀。但行人也要注意自我保护，交通事故中只要稍稍有点不轻的伤，绝大多数会有后遗症，让你终生不能磨灭。 　　所以，与其把身家性命交给一干不相识更不能信任的人，到不如牢牢掌握在自己手中？各位看客多多考虑下吧。]]></description>
			<content:encoded><![CDATA[<p>　　加班至二十一点回家，以科韵路几个路口，等待过马路的行人居然不少。真杯具，现代人都干什么去了，这么晚还在路上，莫非都加班？不过在一众白领（工资白领）中，难得见到一家三口——两公婆与一个八、九岁的娃，我想，这众人中，就这家子最快乐了。</p>
<p>　　这里的每个马路口至少有两个方面的车流。现在是回头转向的机动车绿灯，通常要等好一会，左转机动车灯也绿了，等左转的车流过了，才轮到行人过斑马线。要是平时，回头的车很少，三条车道中只要看最左边的没车了就可以过了，但现在回头的车居然很多，我想占点小便宜也不行。无奈只有等，看风景，数时间，看对面马路的美女，看机动车灯由一条车流到两条车流变绿，再齐齐变黄，变红，然后回头看斑马线上的行人灯，也由红变绿。要说黄灯是危险的时候不为过，一辆辆车都在黄灯时加速，赶在红灯前冲刺。这可不是黄灯设计的本意啊。所以虽然斑马线绿灯了，行人也只有看看车都愿意停了，才马过马路。</p>
<p>　　对面马路的美女动了，一家三口也动了，随之迈步。其中小孩的动作最快，蹦跳着就要走到马路中间，突然一辆一层楼高土黄色的泥头车高速飞过来，我一惊，马上停步，正想往后蹬的同时看见那小孩就要被撞上。不好，我想上去拉，双脚想改为向前蹬，但起码有５步远，来不及了，脚已不听使唤，停住了！脚虽然没有动，身体还是微微前倾，伸手想去拉。没用！根本就够不着，手在空中，更多的像是在指挥。我力不能及，听天由命吧！何止是我？刹那间，几乎同时的，我马路这边的人包括我都在大呼：“嘿，小心！”<br />
<span id="more-629"></span><br />
　　“嗡~”泥头车的声音由远及近，仰面压来——</p>
<p>　　就在这时，小孩突然停住了，他退后了一步！</p>
<p>　　与此同时，泥头车微微往右一侧！</p>
<p>　　就这样，在双方的一个轻微避让下，泥头车与小孩几乎是相隔不到30公分的距离呼啸而过，从右到左地！</p>
<p>　　紧接着，泥头车车身还突然啪哒的一声翠响，然后一些玻璃落地的声音响起。原来是小孩的大人很愤怒的边骂边向泥头车扔了个东西。</p>
<p>　　泥头车稍稍慢了一下，似乎想停下来查看，但我们这群行人似乎都同时看过去，想打架，太好了，我好久没打过架了，正好想发泄一下呢。然而可惜，泥头车还是扬长而去，瞬间消失在路灯与混乱的黑夜中。</p>
<p>　　好险啊！</p>
<p>　　现在想起那一刹那，危险极了，原来我是那么冲动，居然想冲出去拉！我晕，我想如果我真的这么做了，我就已经挂了，这不是死神来了么？</p>
<p>　　马路如杀手啊。</p>
<p>　　我看到很多人都贪方便，走捷径，不走行斑马线爱走内弯，认为内弯安全，还认为是多高明，有胆色，有气概。其实不知多丑陋。这是一种小农意识，贪小便宜，为了一点东西，拼了命去做。太不值得了。把自己的性命交给一些毫不认识的人，多愚昧。为了赶几分钟，省几步脚力，却赌上自己的命，这投入产出比太小了，即使胜利，所得也不过是生命中相比与九牛一毛的蝇头小利，不费吹灰之力就可打发走的时间，以及不花分文就可储存起来的体力，一时之快，却是代价惨重。</p>
<p>　　如果你说我没胆色？错了，我的胆色不会用在愚蠢的地方，我会考虑投入产出。如果拿我的性命去赌，能换来让我满意的金钱，更有甚者是比生命更为之华丽的收获，我会赌上一吧。这个时候，你会吗？我怕你会不敢，你甚至还会退而求其次，心想：我还是每天赚点蝇头小利，日子得过且过吧。</p>
<p>　　贪一时之快，是大众人的心里，包括我在内，所以无论如何，我都会强忍，练耐性也好，总之在众人认为好而我又不屑的，我会告诉自己：不随波逐流，就要耐得住寂寞。</p>
<p>　　有时候三五狗友，劝赌劝酒，三缺一，赌上一次嘛，没关系的。事实上，当别人想劝你做一件事时，再大的关系，都会说成没关系，通过安抚，或激将之法，让你参与其中，多数人都会动容。过后你或后悔莫及，或上瘾。其实看狗友与挚友的分别，就在当他在干自己认为不良的事时，有没有把你拉进水的欲望。</p>
<p>　　话题似乎扯远了，但像国人对交通规则的遵守方面，其实都是与日常人们的相互影响相互榜样离不开的。想想，如果你有开过车，你会很怕行人。其实，当作为行人的你，也要为司机的心里想想，万一那个路人突然冲出来怎么办？行人是弱势群体，国家制定的保护行人的交通规则正是体现了人文情怀。但行人也要注意自我保护，交通事故中只要稍稍有点不轻的伤，绝大多数会有后遗症，让你终生不能磨灭。</p>
<p>　　所以，与其把身家性命交给一干不相识更不能信任的人，到不如牢牢掌握在自己手中？各位看客多多考虑下吧。</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=629&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2010/07/road-cry.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>flash预加载bytesTotal计数错误解决方法</title>
		<link>http://blog.guitarbean.com/2010/06/pre-loaded-flash-bytestotal-error.html</link>
		<comments>http://blog.guitarbean.com/2010/06/pre-loaded-flash-bytestotal-error.html#comments</comments>
		<pubDate>Wed, 09 Jun 2010 16:34:20 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=616</guid>
		<description><![CDATA[　　这两天做的项目中，同事Lam发现页面的flash加载器出现了诡异现象：一个SWF加载另一个SWF文件时，本来应该是加载进度监听的百分比，却出现了Infinity，无穷大，进度条也乱成一团。一开始以为是这位同事的浏览器和环境问题，检查后发现原来是loader的bytesTotal始终为0，即flash player无法得知加载中的文件的大小。[关于LoaderInfo.bytesTotal] 　　感谢同事小魏过来帮忙。我们尝试了用另外一种加载方法进行加载，把Loader改为URLLoader，并用URLLoaderDataFormat.BINARY，即二进制的方式进行加载，可惜没有什么改善啊。 　　无奈之余，上网查证，google真是个好东西，在国外的页面中翻出了为数不多的相同的条目，终于找到了Flash Preloading Errors? Turn Off gzip。文章里说的意思是，通过服务器gzip压缩的swf文件的MIME type被修改成为“text/plain”，但改成正确的“application/x-shockwave-flash”也无法解决，最后不得不把gzip关掉。所以结论是，在没其它方法前，只有把服务器的gzip关掉了咯。 　　但gzip是个好东西，在网络传输的过程中进行压缩，大大的加快页面的浏览速度。而且本文章说到的bytesTotal计数错误貌似只有在IE中才会出现。 　　那，怎么解决呢？我还没找到，只有把要加载的SWF bytesTotal先算出来，以防万一了： percent = loader.bytesLoaded/(loader.bytesTotal &#124;&#124; tempBytesTotal)//tempBytesTotal=文件大小 　　如果要动态计算文件的大小，这招就有点难了，要么关gzip，要么服务器预告知要传送的文件的bytes。 　　此处抛砖引玉，期待更好的方法。]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="actionscript" src="http://farm5.static.flickr.com/4011/4685749590_cd059d1a3e_m.jpg" alt="" width="240" height="180" />　　这两天做的项目中，同事Lam发现页面的flash加载器出现了诡异现象：一个SWF加载另一个SWF文件时，本来应该是加载进度监听的百分比，却出现了Infinity，无穷大，进度条也乱成一团。一开始以为是这位同事的浏览器和环境问题，检查后发现原来是loader的bytesTotal始终为0，即flash player无法得知加载中的文件的大小。[<a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html#bytesTotal" target="_blank">关于LoaderInfo.bytesTotal</a>]</p>
<p><a href="http://www.flickr.com/photos/brajeshwar/493672408/"></a></p>
<p>　　感谢同事小魏过来帮忙。我们尝试了用另外一种加载方法进行加载，把<a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html" target="_blank">Loader</a>改为<a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/net/URLLoader.html" target="_blank">URLLoader</a>，并用URLLoaderDataFormat.BINARY，即二进制的方式进行加载，可惜没有什么改善啊。<span id="more-616"></span></p>
<p>　　无奈之余，上网查证，google真是个好东西，在国外的页面中翻出了为数不多的相同的条目，终于找到了<a href="http://patrickmcd.com/2009/04/20/flash-preloading-errors-turn-off-gzip/" target="_blank">Flash Preloading Errors? Turn Off gzip</a>。文章里说的意思是，通过服务器gzip压缩的swf文件的MIME type被修改成为“text/plain”，但改成正确的“application/x-shockwave-flash”也无法解决，最后不得不把gzip关掉。所以结论是，在没其它方法前，只有把服务器的gzip关掉了咯。</p>
<p>　　但gzip是个好东西，在网络传输的过程中进行压缩，大大的加快页面的浏览速度。而且本文章说到的bytesTotal计数错误貌似只有在IE中才会出现。</p>
<p>　　那，怎么解决呢？我还没找到，只有把要加载的SWF bytesTotal先算出来，以防万一了：</p>
<p><code>percent = loader.bytesLoaded/(loader.bytesTotal || tempBytesTotal)//tempBytesTotal=文件大小</code></p>
<p>　　如果要动态计算文件的大小，这招就有点难了，要么关gzip，要么服务器预告知要传送的文件的bytes。</p>
<p>　　此处抛砖引玉，期待更好的方法。</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=616&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2010/06/pre-loaded-flash-bytestotal-error.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>准备写一轮博客了</title>
		<link>http://blog.guitarbean.com/2010/06/ready-to-write.html</link>
		<comments>http://blog.guitarbean.com/2010/06/ready-to-write.html#comments</comments>
		<pubDate>Wed, 02 Jun 2010 16:24:06 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>
		<category><![CDATA[totoro]]></category>
		<category><![CDATA[龙猫]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=610</guid>
		<description><![CDATA[　　好久没更新了，早段时间空间过期，现在换了个美国主机空间，从程序上来看，运行比JP空间兼容性更好些。 　　同事说博客是一个坑，微博是空气。不过我也已经不上微博好久了，因为锄头说我上微博，知道真相太多了，变不纯洁了，在理，微博比博客更容易让人上瘾呢。不过，我还是把我的微博地址贴出来吧，看到此贴的朋友可以加个关注。不过先说明，我差不多不上了，但不代表不会上，哈哈。 Twitter: http://twitter.com/govo 网易微博：http://t.163.com/jerry 　　传说中的大牛都是很忙的，我这个假大牛，也忙了很多一段时间了，当然，忙是有很多方面的，除了工作，还有生活啊什么的，总之，一塌糊涂。是时候整理一下了，想想目标，理想什么的，今年要想办法提升点什么，否则对不住自己。 　　对了，刚才在ＱＱ群的那些很淫荡的图片里找到一个让我大爱的图——现实版totoro，笑了我半个钟，哈哈哈哈！ 　　在等车时多多留意周围的事物，说不定它就悄悄的出现在你后面，哈哈！]]></description>
			<content:encoded><![CDATA[<p>　　好久没更新了，早段时间空间过期，现在换了个美国主机空间，从程序上来看，运行比JP空间兼容性更好些。</p>
<p>　　同事说博客是一个坑，微博是空气。不过我也已经不上微博好久了，因为锄头说我上微博，知道真相太多了，变不纯洁了，在理，微博比博客更容易让人上瘾呢。不过，我还是把我的微博地址贴出来吧，看到此贴的朋友可以加个关注。不过先说明，我差不多不上了，但不代表不会上，哈哈。</p>
<p style="padding-left: 30px;">Twitter: <a href="http://twitter.com/govo">http://twitter.com/govo</a></p>
<p style="padding-left: 30px;">网易微博：<a href="http://t.163.com/jerry">http://t.163.com/jerry</a></p>
<p>　　传说中的大牛都是很忙的，我这个假大牛，也忙了很多一段时间了，当然，忙是有很多方面的，除了工作，还有生活啊什么的，总之，一塌糊涂。是时候整理一下了，想想目标，理想什么的，今年要想办法提升点什么，否则对不住自己。</p>
<p>　　对了，刚才在ＱＱ群的那些很淫荡的图片里找到一个让我大爱的图——现实版<a title="什么是totoro" href="http://blog.guitarbean.com/2007/08/is-totoro-a-mouse.html">totoro</a>，笑了我半个钟，哈哈哈哈！</p>
<p style="text-align: center;"><a href="http://blog.guitarbean.com/wp-content/uploads/2010/06/qwq42.jpg"><img class="size-medium wp-image-611 aligncenter" title="TOTORO " src="http://blog.guitarbean.com/wp-content/uploads/2010/06/qwq42.jpg" alt="" /></a></p>
<p>　　在等车时多多留意周围的事物，说不定它就悄悄的出现在你后面，哈哈！</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=610&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2010/06/ready-to-write.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript3读取XML</title>
		<link>http://blog.guitarbean.com/2009/12/actionscript3-reading-xml.html</link>
		<comments>http://blog.guitarbean.com/2009/12/actionscript3-reading-xml.html#comments</comments>
		<pubDate>Mon, 14 Dec 2009 03:27:39 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[网络技术]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=510</guid>
		<description><![CDATA[摘要：本文内容大部分来自Using XML in Flash CS3/AS3（英文），主要是做一下笔记以及一个小小的外延。 正文： 对于如下的一个XML文档，在flash中应该怎么读呢？ (图片来自kirupa.com) 按照Using XML in Flash CS3/AS3上的内容，包括了XML结构介绍等内容，在此我不再转述，对XML不怎么了解的话请先移步：XML 系列教程。 这里我分三步描述flash读XML的基本方法，以及外延一个对带命名空间的XML的读取方法，如下目录： 1、加载XML文件； 2、读取XML的数据； 3、过滤数据； 4、读取带命名空间的XML数据； 5、处理gb2312编码的XML； 注：在这里的AS脚本都是在 Adobe Flash CS3 版本以上中进行编写，flex用户请自行添加修改相应的包引用。 下面开始第一部分，如何加载XML文件！ 1、加载XML文件 在脚本编辑器中写入以下代码： var xmlLoader:URLLoader = new URLLoader&#40;&#41;; var xmlData:XML = null; &#160; xmlLoader.addEventListener&#40;Event.COMPLETE, LoadXML&#41;; xmlLoader.load&#40;new URLRequest&#40;&#34;http://www.kirupa.com/net/files/sampleXML.xml&#34;&#41;&#41;; &#160; function LoadXML&#40;e:Event&#41;:void &#123; xmlData = new XML&#40;e.target.data&#41;; trace&#40;xmlData&#41;; &#125; 按Ctrl+Enter运行它，你会在输出窗口中看到整个XML的内容： 这里不进行代码解说，关于XML类，请查看：http://help.adobe.com/zh_TW/AS3LCR/Flash_10.0/XML.html 下面进入第2部分：如何读取XML数据。 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>摘要：</strong>本文内容大部分来自<a href="http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm">Using XML in Flash CS3/AS3</a>（英文），主要是做一下笔记以及一个小小的外延。</p>
<p><strong>正文：</strong></p>
<p>对于如下的一个XML文档，在flash中应该怎么读呢？</p>
<p><a href="http://www.kirupa.com/net/images/xml_doc2.gif"><img class="alignnone" title="XML样例" src="http://www.kirupa.com/net/images/xml_doc2.gif" alt="" width="363" height="274" /></a></p>
<p>(图片来自kirupa.com)</p>
<p>按照<a href="http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm">Using XML in Flash CS3/AS3</a>上的内容，包括了XML结构介绍等内容，在此我不再转述，对XML不怎么了解的话请先移步：<a href="http://www.w3school.com.cn/x.asp">XML 系列教程</a>。</p>
<p>这里我分三步描述flash读XML的基本方法，以及外延一个对带命名空间的XML的读取方法，如下目录：</p>
<p>1、加载XML文件；<br />
2、读取XML的数据；<br />
3、过滤数据；<br />
4、读取带命名空间的XML数据；<br />
5、处理gb2312编码的XML；</p>
<p>注：在这里的AS脚本都是在 Adobe Flash CS3 版本以上中进行编写，flex用户请自行添加修改相应的包引用。</p>
<p>下面开始第一部分，如何加载XML文件！<br />
<span id="more-510"></span></p>
<h3>1、加载XML文件</h3>
<p>在脚本编辑器中写入以下代码：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> xmlLoader:URLLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> xmlData:<span style="color: #0066CC;">XML</span> = <span style="color: #000000; font-weight: bold;">null</span>;
&nbsp;
xmlLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, LoadXML<span style="color: #66cc66;">&#41;</span>;
xmlLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://www.kirupa.com/net/files/sampleXML.xml&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> LoadXML<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  xmlData = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>xmlData<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>按Ctrl+Enter运行它，你会在输出窗口中看到整个XML的内容：<br />
<img src="http://www.kirupa.com/developer/flashcs3/images/xmlOutputWindow.png" alt="输出窗口" /><br />
这里不进行代码解说，关于XML类，请查看：http://help.adobe.com/zh_TW/AS3LCR/Flash_10.0/XML.html</p>
<p>下面进入第2部分：如何读取XML数据。</p>
<h3>2、读取XML数据</h3>
<h4>2.1直接读取XML数据</h4>
<p>对XML数据的读取是十分简单的，不信请看：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> LoadXML<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  xmlData = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
  ParseBooks<span style="color: #66cc66;">&#40;</span>xmlData<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookInput.<span style="color: #006600;">Book</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>可得到如何结果：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">XML Output
------------------------
&nbsp;
  Sir Arthur Conan Doyle
&nbsp;
  F. Scott Fitzgerald
&nbsp;
  Stephen E. Ambrose
&nbsp;
  Stephen E. Ambrose</pre></div></div>

<p>同样的，把trace的内容改为bookInput.Book.author，会得到下面的结果：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">XML Output
------------------------
Sir Arthur Conan Doyle
F. Scott Fitzgerald
Stephen E. Ambrose
Stephen E. Ambrose</pre></div></div>

<p>而trace(bookInput.Book.author.text());可得到：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">XML Output
------------------------
Sir Arthur Conan DoyleF. Scott FitzgeraldStephen E. AmbroseStephen E. Ambrose</pre></div></div>

<p>同样的，要读具体的节点，可以这样</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookInput.<span style="color: #006600;">Book</span>.<span style="color: #006600;">author</span>.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>可得到</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">XML Output
------------------------
Sir Arthur Conan Doyle</pre></div></div>

<h4>2.2、XML和XMLList</h4>
<p>这里我们会用到另外一个类XMLList，这个类可以把XML对象作为数组的方式读取，可以方便地进行for each操作。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> authorList:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #006600;">author</span>;
  <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> authorElement:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> authorList<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>authorElement<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h4> 2.3历遍子元素</h4>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> bookChildren:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> bookInfo:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> bookChildren<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookInfo<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>结果如下：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">XML Output
------------------------
Sherlock Holmes: Complete Novels and Stories, Vol 1
Sir Arthur Conan Doyle
The Great Gatsby
F. Scott Fitzgerald
Undaunted Courage
Stephen E. Ambrose
Nothing Like It In the World
Stephen E. Ambrose</pre></div></div>

<p>同样的，我们可以用节点的.name()方法得知它的标签名：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> bookChildren:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> bookInfo:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> bookChildren<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>bookInfo.<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot;author&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookInfo<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>这样就可以得到所有author的值了。</p>
<h4>2.4读取属性</h4>
<p>历遍属性的方法：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #000000; font-weight: bold;">var</span> bookAttributes:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #0066CC;">attributes</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> bookISBN:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> bookAttributes<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookISBN<span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #66cc66;">&#125;</span> 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>对于attributes，同样有一个.name()方法：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #000000; font-weight: bold;">var</span> bookAttributes:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #0066CC;">attributes</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> bookISBN:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> bookAttributes<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>bookISBN.<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot;ISBN&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
      <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookISBN<span style="color: #66cc66;">&#41;</span>; 
    <span style="color: #66cc66;">&#125;</span> 
  <span style="color: #66cc66;">&#125;</span> 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>另外还有一种更直接的方法，直接用.attribute(&#8220;ISBN&#8221;) ：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #000000; font-weight: bold;">var</span> bookAttributes:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #006600;">attribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ISBN&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> bookISBN:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> bookAttributes<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookISBN<span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #66cc66;">&#125;</span> 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>注意，这个.attribute(attributeName:*)方法不是.attributes()哦，少了个s的哦。</p>
<h3>3、过滤数据</h3>
<h4>3.1过滤值</h4>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #000000; font-weight: bold;">var</span> authorList:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #66cc66;">&#40;</span>author == <span style="color: #ff0000;">&quot;Stephen E. Ambrose&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>authorList<span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>可得到：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">XML Output
------------------------
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Book</span> <span style="color: #000066;">ISBN</span>=<span style="color: #ff0000;">&quot;0684826976&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Undaunted Courage<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Stephen E. Ambrose<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Book<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Book</span> <span style="color: #000066;">ISBN</span>=<span style="color: #ff0000;">&quot;0743203178&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Nothing Like It In the World<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Stephen E. Ambrose<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Book<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>所以在过滤之后，可以同样使用</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> authorList:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #66cc66;">&#40;</span>author == <span style="color: #ff0000;">&quot;Stephen E. Ambrose&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">title</span>;</pre></div></div>

<p>得到所有作者是Stephen E. Ambrose的书名了。</p>
<h4>3.2过滤属性</h4>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #000000; font-weight: bold;">var</span> bookList:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">@</span>ISBN == <span style="color: #ff0000;">&quot;0743203178&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">title</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookList<span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>我们还可以进行一些复杂的过滤：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #000000; font-weight: bold;">var</span> bookList:XMLList = bookInput.<span style="color: #006600;">Book</span>.<span style="color: #66cc66;">&#40;</span>author == <span style="color: #ff0000;">&quot;Stephen E. Ambrose&quot;</span> <span style="color: #66cc66;">&amp;&amp;</span> title <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">&quot;Nothing Like It In the World&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">title</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookList<span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h3>4、读取带命名空间的XML数据</h3>
<p>如果把上面的XML文件改一改，变成如下：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Books</span> <span style="color: #000066;">xmlns:g</span>=<span style="color: #ff0000;">&quot;http://guitarbean.com/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Book</span> <span style="color: #000066;">ISBN</span>=<span style="color: #ff0000;">&quot;0553212419&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Sherlock Holmes: Complete Novels and Stories, Vol 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Sir Arthur Conan Doyle<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Book<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Book</span> <span style="color: #000066;">ISBN</span>=<span style="color: #ff0000;">&quot;0743273567&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>The Great Gatsby<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>F. Scott Fitzgerald<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Book<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Book</span> <span style="color: #000066;">ISBN</span>=<span style="color: #ff0000;">&quot;0684826976&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Undaunted Courage<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Stephen E. Ambrose<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Book<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Book</span> <span style="color: #000066;">ISBN</span>=<span style="color: #ff0000;">&quot;0743203178&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Nothing Like It In the World<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Stephen E. Ambrose<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;g:cost<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>XXXXXXX<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/g:cost<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Book<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Books<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>这时要用到Namespace类了：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseBooks<span style="color: #66cc66;">&#40;</span>bookInput:<span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;XML Output&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;------------------------&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> g:Namespace = <span style="color: #000000; font-weight: bold;">new</span> Namespace<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://guitarbean.com/&quot;</span><span style="color: #66cc66;">&#41;</span>; 
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>bookInput.<span style="color: #006600;">Book</span>.<span style="color: #006600;">g</span>::cost<span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>可得到：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">XML Output
------------------------
XXXXXXX</pre></div></div>

<p>这里的双冒号(::)就是命名空间符，只要建立了一Namespace对象，XML对象便可直接用点运算符来操作了，相对的比较方便。</p>
<h3>5、处理gb2312编码的XML</h3>
<p>有的XML文件可能不是UTF8的，如在中国常用的gb2312编码，侧需要转码一下，这时要用到ByteArray类，在建立XML对象前统一处理下即可：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> xmlLoader:URLLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> xmlData:<span style="color: #0066CC;">XML</span> = <span style="color: #000000; font-weight: bold;">null</span>;
&nbsp;
xmlLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, LoadXML<span style="color: #66cc66;">&#41;</span>;
xmlLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://www.kirupa.com/net/files/sampleXML.xml&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> LoadXML<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> BA:ByteArray = <span style="color: #000000; font-weight: bold;">new</span> ByteArray;
  BA.<span style="color: #006600;">writeBytes</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> as URLLoader<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
  BA.<span style="color: #0066CC;">position</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
  <span style="color: #808080; font-style: italic;">//把gb2312转为UTF8编码：</span>
  <span style="color: #000000; font-weight: bold;">var</span> newData:<span style="color: #0066CC;">String</span> = BA.<span style="color: #006600;">readMultiByte</span><span style="color: #66cc66;">&#40;</span>BA.<span style="color: #0066CC;">length</span>,<span style="color: #ff0000;">&quot;gb2312&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #808080; font-style: italic;">//然后才建立XML对象：</span>
  xmlData = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>newData<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>xmlData<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>此部分内容参照自：<a href="http://www.lizuole.com.cn/article.asp?id=59">http://www.lizuole.com.cn/article.asp?id=59</a></p>
<p>【完】</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=510&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/12/actionscript3-reading-xml.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>IE运行时设置name属性的BUG</title>
		<link>http://blog.guitarbean.com/2009/07/setting-the-name-attribute-in-internet-explorer.html</link>
		<comments>http://blog.guitarbean.com/2009/07/setting-the-name-attribute-in-internet-explorer.html#comments</comments>
		<pubDate>Sat, 11 Jul 2009 07:39:13 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=496</guid>
		<description><![CDATA[在刚完成的项目中遇到用javascript动态创建的单选按钮在IE中无法选中的情况，在排除脚本逻辑错误后百思不得其解的情况下搜索到原来这是个IE下的BUG： The NAME attribute cannot be set at run time on elements dynamically created with the createElement method. To create an element with a name attribute, include the attribute and value when using the createElement method. 中文的文章可以看这里http://www.javaeye.com/topic/26917。 其中两个参考文献链接： http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/， http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/ 这个BUG使得无法使用document.createElement(&#8220;input&#8221;); 创建我们想要的input标签，但可以这样： document.createElement&#40;'&#60;input type=&#34;radio&#34; name=&#34;username&#34; &#62;'&#41;; 当然这不是W3C支持的做法，所以在FF中无效，全面一点的函数是： function createElement&#40;type, name&#41; &#123; var element = null; [...]]]></description>
			<content:encoded><![CDATA[<p>在刚完成的项目中遇到用javascript动态创建的单选按钮在IE中无法选中的情况，在排除脚本逻辑错误后百思不得其解的情况下搜索到原来这是个IE下的BUG：</p>
<blockquote><p>The NAME attribute cannot be set at run time on elements dynamically created with the createElement method. To create an element with a name attribute, include the attribute and value when using the createElement method.</p>
</blockquote>
<p>中文的文章可以看这里<a href="http://www.javaeye.com/topic/26917">http://www.javaeye.com/topic/26917</a>。</p>
<p>其中两个参考文献链接：</p>
<p><a href="http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/">http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/</a>，</p>
<p><a href="http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/">http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/</a></p>
<p>这个BUG使得无法使用document.createElement(&#8220;input&#8221;); 创建我们想要的input标签，但可以这样：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;input type=&quot;radio&quot; name=&quot;username&quot; &gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>当然这不是W3C支持的做法，所以在FF中无效，全面一点的函数是：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> createElement<span style="color: #009900;">&#40;</span>type<span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003366; font-weight: bold;">var</span> element <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #006600; font-style: italic;">// First try the IE way; if this fails then use the standard way</span>
      element <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;'</span><span style="color: #339933;">+</span>type<span style="color: #339933;">+</span><span style="color: #3366CC;">' name=&quot;'</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot;&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #006600; font-style: italic;">// Probably failed because we’re not running on IE</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>element<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      element <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span>type<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      element.<span style="color: #000066;">name</span> <span style="color: #339933;">=</span> <span style="color: #000066;">name</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000066; font-weight: bold;">return</span> element<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>然后对属性的设置需要使用：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">element.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;radio&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>如果你使用了jQuery，可以直接使用jQuery(html)来创建它： </p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">elm<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;input type=&quot;radio&quot; name=&quot;username&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>不过，jQuery这个方法也得先把type写进去，否则会抛出<strong>uncaught exception: type property can&#8217;t be changed</strong>异常。</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p><strong><ins datetime="2009-09-02T08:35:41+00:00">2009年鬼节补充更新：</ins></strong><br />
看到<a href="http://leafin.cn/">叶虫</a>同学说这不叫BUG，于是我又上去查一下，就看到这了个<a href="http://msdn.microsoft.com/en-us/library/ms534184(VS.85).aspx">http://msdn.microsoft.com/en-us/library/ms534184(VS.85).aspx</a>，其中有这样的备注：</p>
<p></p>
<blockquote><p>Internet Explorer 8 and later. In IE8 mode, dynamically setting the name attribute on an input type=radio button correctly applies that button to the same named group. For more information on IE8 mode, see Defining Document Compatibility.</p></blockquote>
<p>大致意思是：IE8及以后的版本中，type=radio的单选按钮已经可以正常设置了。然后下面又有一段：</p>
<blockquote><p>Internet Explorer 8 and later can set the NAME attribute at run time on elements dynamically created with the createElement method. To create an element with a NAME attribute in earlier versions of Internet Explorer, include the attribute and its value when using the createElement method.</p></blockquote>
<p>大致意思是说，IE8及以后的版本中，即使使用createElement在运行时创建的元素，也可以设置它的NAME属性了；而至于较早版本的IE，就需要在createElement创建时就指定一个name属性了。<br />
不过下面这行我又不知道是什么意思了，因为看不明白所指的programming model 是什么，请看：</p>
<blockquote><p>Microsoft JScript allows the name to be changed at run time. This does not cause the name in the programming model to change in the collection of elements, but it does change the name used for submitting elements.</p></blockquote>
<p>我不懂DOM的内在机理，于是上去查了一下<a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html">Document Object Model Core（DOM核心）</a>，从Interface Node章节，Interface NodeList章节以及Interface NamedNodeMap章节粗略了解到，DOM在机器内部运算时还定义了一些接口，如NodeList接口，NamedNodeMap接口等。</p>
<p>这些都是一些内在的机理了，估计在开发浏览器或者一些很高级的应用才要关注到。而我们这里所说的name属性，其实就是指Interface Node接口中当nodeType为ATTRIBUTE_NODE时的一个实例了，而不是其它。简单点说，就是此NAME非彼NAME，一个分子级别，一个是原子级别。</p>
<p>Microsoft JScript对DOM的运行机理可能不一样，但上面那行英文应该也是这个意思。或者就是想告诉我们，改变这个name可以用来提交表单什么的，但想改变IE内部的运行机理，这就不行了。</p>
<p><strong>关于Javascript与Microsoft JScript：</strong><br />
从<a href="http://it.toolbox.com/blogs/web2-place/the-difference-between-javascript-and-jscript-16697">这里《The Difference Between JavaScript and JScript》</a>以及其评论，可以看出Javascript与Microsoft JScript的分别：<br />
<strong>Javascript</strong>         ：最早是Netscape开发的一套脚本语言，现在谈起它，就是指W3C标准里的那个ECMA Script；<br />
<strong>Microsoft JScript</strong>：Microsoft 在其浏览器IE里对Javascript的实现，虽然它并没有完全地实现Javascript的特性，但也增加了一些Javascript所没有的。</p>
<p>所以从我们老生常谈的WEB标准角度，我们当然希望无论是Microsoft JScript还是其它浏览器所实现的JScript都跟标准的ECMA Script是一个样了，这样无论对开发者还是用户都是件好事 <img src='http://blog.guitarbean.com/wp-includes/images/smilies/icon_wink.gif' alt=':wink:' class='wp-smiley' />  。</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=496&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/07/setting-the-name-attribute-in-internet-explorer.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>wordpress2.8升级失败中</title>
		<link>http://blog.guitarbean.com/2009/06/wordpress28-upgrade-failure.html</link>
		<comments>http://blog.guitarbean.com/2009/06/wordpress28-upgrade-failure.html#comments</comments>
		<pubDate>Sat, 20 Jun 2009 11:20:05 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=493</guid>
		<description><![CDATA[在升级到2.8时似乎失败了，出现的问题是后台一片混乱，只有回退到2.7了，使得当中一些侧栏工具重新设置了一下，目前情况不怎么好，等待2.8.1再升ORZ]]></description>
			<content:encoded><![CDATA[<p>在升级到2.8时似乎失败了，出现的问题是后台一片混乱，只有回退到2.7了，使得当中一些侧栏工具重新设置了一下，目前情况不怎么好，等待2.8.1再升ORZ</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=493&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/06/wordpress28-upgrade-failure.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A video of CSXY</title>
		<link>http://blog.guitarbean.com/2009/05/a-video-of-csxy.html</link>
		<comments>http://blog.guitarbean.com/2009/05/a-video-of-csxy.html#comments</comments>
		<pubDate>Mon, 04 May 2009 17:41:09 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=486</guid>
		<description><![CDATA[Hi guys, did you remember the game &#8220;Genesis Journey to the West&#8220;? I&#8217;ve made a short introduce here. Now ,here is a video of the game. It was created by the players while playing it. Take a look and have fun! 创世西游官方论坛及178论坛同步发布]]></description>
			<content:encoded><![CDATA[<p>Hi guys, did you remember the game &#8220;<a href="http://csxy.163.com/">Genesis Journey to the West</a>&#8220;? I&#8217;ve made a short introduce <a href="http://blog.guitarbean.com/2009/04/genesis-journey-to-the-west.html">here</a>.<br />
Now ,here is a video of the game. It was created by the players while playing it. Take a look and have fun!<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="420" height="363" align="middle"><param name="movie" value="http://www.tudou.com/v/Un90I2bqjlA" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="http://www.tudou.com/v/Un90I2bqjlA" quality="high" width="420" height="363" align="middle" allowScriptAccess="always" allowFullScreen="true" wmode="transparent" type="application/x-shockwave-flash" /></object><br />
创世西游官方论坛及178论坛同步发布</p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=486&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/05/a-video-of-csxy.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Genesis Journey to the West</title>
		<link>http://blog.guitarbean.com/2009/04/genesis-journey-to-the-west.html</link>
		<comments>http://blog.guitarbean.com/2009/04/genesis-journey-to-the-west.html#comments</comments>
		<pubDate>Sun, 05 Apr 2009 10:35:26 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[genesis]]></category>
		<category><![CDATA[online game]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=477</guid>
		<description><![CDATA[Genesis Journey to the West is the most sepecial online game I have ever seen in China with it&#8217;s beautiful art style. The background story of the game is an ancient Chinese Myths about how the world was created. It is said that the world is created by giant Pangu.He broke the the cosmic egg then [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://csxy.163.com/"><img class="size-full" title="csxy" src="http://blog.guitarbean.com/wp-content/uploads/2009/04/qxxz.jpg" alt="csxy" width="458" height="210" /></a></p>
<p>Genesis Journey to the West is the most sepecial online game I have ever seen in China with it&#8217;s beautiful art style.</p>
<p>The background story of the game is an ancient Chinese Myths about how the world was created.</p>
<p>It is said that the world is created by giant Pangu.He broke the the cosmic egg then the sky and the earth was  formed. when he died, his body went to make the world and all its elements.For example his voice was thunder and lightning, his left eye became the sun and the right one become moon. And the parasites on his body became the divers races of humankind, and so on.(<a href="http://www.livingmyths.com/Chinese.htm">Chinese Myths</a>.)</p>
<p>As the human become more and more clever, they got more and more powers and skills.Then the six main races of humankind were formed.</p>
<p>Two of the human races were  <em>Xiuluo</em> and <em>Tiandao</em>. They hated each other and fight for years. In one of the fightings, the King of <em>Xiuluo</em> ,called <em>XiuluoWang</em> was defeated,and his soul was putted in to a stone.Days later,that stone was exploded a monkey was borned. This was the Monkey King, Sun Wukong, which was knew by all nowadays.</p>
<p>That was the backound story of online game Genesis Journey to the West. The game is on beta now. If you are interested in it, <a href="http://survey2.163.com/html/parttime_tester_recruiting/paper.html">you can apply for a serial number here</a> . <a href="http://csxy.163.com/download/client.html">Download</a> the game, <a href="http://csxy.163.com/">home page</a> of the game, <a href="http://csxy.netease.com/">forum</a> of the game, and <a href="http://csxy.163.com/photo/painting.html">arts of the game</a>.</p>
<p><span class="trans">Here is  some arts of the game:</span><br />
<a href="http://csxy.163.com/photo/painting.html"><img src="http://farm4.static.flickr.com/3550/3414366572_881ffaa5cd_m.jpg" alt="" /></a><a href="http://csxy.163.com/photo/painting.html"><img src="http://farm4.static.flickr.com/3203/3413561079_da9d3981aa_m.jpg" alt="" /></a><a href="http://csxy.163.com/photo/painting.html"> <img src="http://farm4.static.flickr.com/3048/3413561805_0ceb977855_m.jpg" alt="" /></a><a href="http://csxy.163.com/photo/painting.html"><img src="http://farm4.static.flickr.com/3318/3414368302_cb5a8a90ac_m.jpg" alt="" /><br />
</a></p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=477&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/04/genesis-journey-to-the-west.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>解决AS3自定义滑鼠光标失焦的方法</title>
		<link>http://blog.guitarbean.com/2009/03/solution-as3-custom-mouse-cursor-out-of-focus-method.html</link>
		<comments>http://blog.guitarbean.com/2009/03/solution-as3-custom-mouse-cursor-out-of-focus-method.html#comments</comments>
		<pubDate>Tue, 31 Mar 2009 13:53:38 +0000</pubDate>
		<dc:creator>GOVO</dc:creator>
				<category><![CDATA[其它]]></category>

		<guid isPermaLink="false">http://blog.guitarbean.com/?p=470</guid>
		<description><![CDATA[在flash里自定义滑鼠光标形状是件很容易而且很觉的事件，但在AS3里却有另一个问题，就是鼠标会被自定义的MC元件遮挡住而无法点击下面的元件。 （如果您无法查看此flash，请点击这里查看。） 式神达人说AS2是不会有这个问题的。我觉得，这正是AS3的改进之处：逻辑更规范合理了（当然也有人觉得AS3很累赘很麻烦，因为代码多了 ）。 在这里，当MC手型元件跟着光标跑时，真正的光标焦点就落在MC上了，此时MC手型可被点击，而MC手型下方的就被挡住了，光标就无法穿越MC手型到达下面的物件了，这就是原因。解决方法就是取消MC手型的光标，让它不可点击，这样光标焦点就可以重新跳到下一层了。 解决方法的关键代码是： myCursor.mouseEnabled = false; myCursor.mouseChildren = false; 为什么AS3要这样做？因为MC手型元件在实质上并不是一个光标，它只是跟着光标运动的一个普通的元件而已，它应该也拥有同样被点击的权利，除非你刻意不允许，而只有不允许时才更适合做一个光标MC。 以上内容参考自：Tips for Using Custom Mouse Cursors in Flash AS3]]></description>
			<content:encoded><![CDATA[<p>在flash里自定义滑鼠光标形状是件很容易而且很觉的事件，但在AS3里却有另一个问题，就是鼠标会被自定义的MC元件遮挡住而无法点击下面的元件。</p>
<p><object width="277" height="125" data="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/custom_mouse_cursors.swf" type="application/x-shockwave-flash"><param name="id" value="custom_mouse_cursorsObject" /><param name="allowScriptAccess" value="always" /><param name="base" value="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/." /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="scale" value="noscale" /><param name="src" value="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/custom_mouse_cursors.swf" /><param name="align" value="middle" /></object><br />
（如果您无法查看此flash，<a href="http://danielmclaren.net/2008/03/tips-for-using-custom-mouse-cursors-in-flash-as3">请点击这里查看</a>。）</p>
<p>式神达人说AS2是不会有这个问题的。我觉得，这正是AS3的改进之处：逻辑更规范合理了（当然也有人觉得AS3很累赘很麻烦，因为代码多了 <img src='http://blog.guitarbean.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ）。</p>
<p>在这里，当MC手型元件跟着光标跑时，真正的光标焦点就落在MC上了，此时MC手型可被点击，而MC手型下方的就被挡住了，光标就无法穿越MC手型到达下面的物件了，这就是原因。解决方法就是取消MC手型的光标，让它不可点击，这样光标焦点就可以重新跳到下一层了。</p>
<p>解决方法的关键代码是：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">myCursor.<span style="color: #660066;">mouseEnabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
myCursor.<span style="color: #660066;">mouseChildren</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></div>

<p>为什么AS3要这样做？因为MC手型元件在实质上并不是一个光标，它只是跟着光标运动的一个普通的元件而已，它应该也拥有同样被点击的权利，除非你刻意不允许，而只有不允许时才更适合做一个光标MC。</p>
<p><object height="125" width="100%" id="custom_mouse_cursors_niceObject" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="always" name="allowScriptAccess"/><param value="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/." name="base"/><param value="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/custom_mouse_cursors_nice.swf" name="movie"/><param value="" name="flashvars"/><param value="high" name="quality"/><param value="#ffffff" name="bgcolor"/><param value="noscale" name="scale"/><embed height="125" width="100%" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" scale="noscale" base="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/." flashvars="" bgcolor="#ffffff" quality="high" src="http://danielmclaren.net/files/public/2008/custom_mouse_cursors/custom_mouse_cursors_nice.swf" id="custom_mouse_cursors_niceEmbed"/> </object></p>
<p>以上内容参考自：<a href="http://danielmclaren.net/2008/03/tips-for-using-custom-mouse-cursors-in-flash-as3">Tips for Using Custom Mouse Cursors in Flash AS3</a></p>
<img src="http://blog.guitarbean.com/?ak_action=api_record_view&id=470&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.guitarbean.com/2009/03/solution-as3-custom-mouse-cursor-out-of-focus-method.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
