<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[WalterShe's blog - 心得体会]]></title>
<link>http://www.flashshe.com/articles/</link>
<description><![CDATA[flex,flash]]></description>
<language>zh-cn</language>
<copyright><![CDATA[Copyright 2005 PBlog3 v2.8]]></copyright>
<webMaster><![CDATA[walt&#101;rshe@126.com()]]></webMaster>
<generator>PBlog2 v2.4</generator> 
<image>
	<title>Walt&#101;rShe&#39;s blog</title>
	<url>http://www.flashshe.com/articles/images/logos.gif</url>
	<link>http://www.flashshe.com/articles/</link>
	<description>Walt&#101;rShe&#39;s blog</description>
</image>

			<item>
			<link>http://www.flashshe.com/articles/article.asp?id=16</link>
			<title><![CDATA[传值(pass by value)的函数调用方式]]></title>
			<author>walt&#101;rshe@126.com(Admin)</author>
			<category><![CDATA[心得体会]]></category>
			<pubDate>Wed,23 Dec 2009 14:53:25 +0800</pubDate>
			<guid>http://www.flashshe.com/articles/default.asp?id=16</guid>
		<description><![CDATA[<strong>2010.3.31补充说明：</strong><br/>我特别奇怪为什么看文章的人不去看我推荐的<br/>1，<strong><a target="_blank" href="http://www.javaranch.com/campfire/StoryPassBy.jsp" rel="external">Pass-by-Value Please (Cup Size continued)</a></strong><br/>2，<strong><a target="_blank" href="http://javadude.com/articles/passbyvalue.htm" rel="external">Java is Pass-by-Value, Dammit!</a></strong><br/>两篇文章呢？？？？算了，再补上一篇中文文章<strong><a target="_blank" href="http://www.xiaoxiaozi.com/2010/03/05/1719/" rel="external"> JavaScript 传递参数是值传递？还是值传递？</a></strong>。<br/><br/>按引用传递应该在c语言里面提到，而后c++语言里面也有，Javascript 应该在c++语言之后出现，actionscript 语言基于javascript语言，所以actionscript 语言出现的最晚。所以我建议读者先看看c/c++语言是怎么解释 按值传递 和 按引用传递 的然后再看我这篇文章。<br/><br/>别太迷信Adobe帮助文档上的胡言乱语，因为写文档的人也只是一个人，他不一定比你高明多少。<br/><br/>写这篇文章的初衷不是想把大家搞糊涂，而是想让大家都知道这个事实，现在看来有点适得其反。看不懂的读者不要钻牛角尖了，会用就行，不懂就不懂，何必强求，这个世界那么多的未知，怎么可能都被你知道呢 <img src="http://www.flashshe.com/articles/images/smilies/Face_03.gif" border="0" style="margin:0px 0px -2px 0px" alt=""/>。<br/>————————————————————————————————————————————————<br/><br/>ActionScript 3函数调用采用的是“按值传递方式”，代码胜千言<br/><div class="UBBPanel codePanel"><div class="UBBTitle"><img src="http://www.flashshe.com/articles/images/code.gif" style="margin:0px 2px -3px 0px" alt="程序代码"/> 程序代码</div><div class="UBBContent"><br/>private var list:Array = [&#34;hello&#34;, &#34;world&#34;, &#34;!&#34;];<br/><br/><br/>private function onInit():void<br/>{<br/>&#160;&#160;&#160;&#160;trace(&#34;befor: &#34; + list.toString());<br/>&#160;&#160;&#160;&#160;test(list);<br/>&#160;&#160;&#160;&#160;trace(&#34;after: &#34; + list.toString());<br/>}<br/><br/>private function test(v:Array):void<br/>{<br/>&#160;&#160;&#160;&#160;v = [&#34;another&#34;, &#34;hello&#34;, &#34;?&#34;];<br/>&#160;&#160;&#160;&#160;trace(v.toString());<br/>}<br/></div></div><br/><br/>输出如下：<br/><div class="UBBPanel codePanel"><div class="UBBTitle"><img src="http://www.flashshe.com/articles/images/code.gif" style="margin:0px 2px -3px 0px" alt="程序代码"/> 程序代码</div><div class="UBBContent"><br/>befor: hello,world,!<br/>another,hello,?<br/>after: hello,world,!<br/></div></div><br/><br/>看完了是不是有点迷惑，不要紧，再仔细想想，想明白就行。<br/><br/>-------------------------------------------------------------------------<br/>2009.12.31补充说明：<br/>Adobe官方帮助文档<strong><a target="_blank" href="http://help.adobe.com/zh_CN/ActionScri&#112;t/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f56.html" rel="external">函数参数-按值或按引用传递参数</a></strong>一节中有这样一句话：<br/><div class="UBBPanel quotePanel"><div class="UBBTitle"><img src="http://www.flashshe.com/articles/images/quote.gif" style="margin:0px 2px -3px 0px" alt="引用内容"/> 引用内容</div><div class="UBBContent">在 ActionScript 3.0 中，所有的参数均按引用传递，因为所有的值都存储为对象。</div></div><br/>我不知道是不是的Adobe的工程师自己本身都没有了解什么是按值传递(pass by value)，什么是按引用传递(pass by reference)，或者是Adobe的工程师对于pass by reference有自己的一套解释？？？<br/>从本质来讲ActionScript 3.0 中，所有的参数均按值传递才对。<br/>按值传递(pass by value)和按引用传递(pass by reference)的精彩解释可以参考下面两篇文章<br/>1，<strong><a target="_blank" href="http://www.javaranch.com/campfire/StoryPassBy.jsp" rel="external">Pass-by-Value Please (Cup Size continued)</a></strong><br/>2，<strong><a target="_blank" href="http://javadude.com/articles/passbyvalue.htm" rel="external">Java is Pass-by-Value, Dammit!</a></strong><br/>-------------------------------------------------------------------------<br/>]]></description>
		</item>
		
			<item>
			<link>http://www.flashshe.com/articles/article.asp?id=9</link>
			<title><![CDATA[ActionScript 3中如何深拷贝(deep copy)一个对象]]></title>
			<author>walt&#101;rshe@126.com(Admin)</author>
			<category><![CDATA[心得体会]]></category>
			<pubDate>Fri,12 Sep 2008 13:52:02 +0800</pubDate>
			<guid>http://www.flashshe.com/articles/default.asp?id=9</guid>
		<description><![CDATA[记得flash帮助文档 Programming ActionScript 3.0 / Core ActionScript 3.0 Data Types and Classes / Working with arrays /Cloning arrays 一节讲了如何深克隆(deep copy)一个数组的方法，以前一直以为这个方法只对数组有用，其实这个方法适用于所有的对象。<br/><br/>下面是我的例子：<br/><div class="UBBPanel codePanel"><div class="UBBTitle"><img src="http://www.flashshe.com/articles/images/code.gif" style="margin:0px 2px -3px 0px" alt="程序代码"/> 程序代码</div><div class="UBBContent"><br/>&lt;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&gt;<br/>&lt;mx:Application xmlns:mx=&#34;<a href="http://www.adobe.com/2006/mxml" target="_blank" rel="external">http://www.adobe.com/2006/mxml</a>&#34; <br/>&#160;&#160;&#160;&#160;layout=&#34;absolute&#34; creationComplete=&#34;completeHandler()&#34;&gt;<br/>&#160;&#160;&#160;&#160;&lt;mx:Script&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;![CDATA[<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;import mx.controls.Button;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;import flash.utils.ByteArray;<br/><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;public function clone(source:Object):*<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&nbsp;&nbsp;&nbsp;&nbsp;var myBA:ByteArray = new ByteArray();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&nbsp;&nbsp;&nbsp;&nbsp;myBA.writeObject(source);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&nbsp;&nbsp;&nbsp;&nbsp;myBA.position = 0;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&nbsp;&nbsp;&nbsp;&nbsp;return(myBA.readObject());<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;private var c1:CloneClass;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;private var c2:Object;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;private function completeHandler():void<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;c1 = new CloneClass();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;c1.age = 30;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;c1.button = new Button;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;c1.button.label = &#34;c1&#34;;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;c2 = clone(c1);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;trace(&#34;c1: &#34; + c1.age + &#34;&nbsp;&nbsp;&#34; + c1.button.label); // 输出 c1: 30&nbsp;&nbsp;c1<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;trace(&#34;c2: &#34; + c2.age + &#34;&nbsp;&nbsp;&#34; + c2.button.label); // 输出 c2: 30&nbsp;&nbsp;c1<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;private function change():void<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;c1.age = 50;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;c1.button.label = &#34;cc1&#34;;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;trace(&#34;after changed --------------------------------&#34;);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;trace(&#34;c1: &#34; + c1.age + &#34;&nbsp;&nbsp;&#34; + c1.button.label); // 输出 c1: 50&nbsp;&nbsp;cc1<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;trace(&#34;c2: &#34; + c2.age + &#34;&nbsp;&nbsp;&#34; + c2.button.label); // 输出 c2: 30&nbsp;&nbsp;c1<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;]]&gt;<br/>&#160;&#160;&#160;&#160;&lt;/mx:Script&gt;<br/>&#160;&#160;&#160;&#160;&lt;mx:Button x=&#34;106&#34; y=&#34;97&#34; label=&#34;Change&#34; click=&#34;change()&#34;/&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br/>&lt;/mx:Application&gt;<br/><br/></div></div><br/><strong>CloneClass 类</strong><br/><div class="UBBPanel codePanel"><div class="UBBTitle"><img src="http://www.flashshe.com/articles/images/code.gif" style="margin:0px 2px -3px 0px" alt="程序代码"/> 程序代码</div><div class="UBBContent"><br/>package<br/>{<br/>&#160;&#160;&#160;&#160;import mx.controls.Button;<br/>&#160;&#160;&#160;&#160;<br/>&#160;&#160;&#160;&#160;public class CloneClass<br/>&#160;&#160;&#160;&#160;{<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;public var button:Button;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;public var age:uint = 1;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;public function CloneClass()<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br/><br/>&#160;&#160;&#160;&#160;}<br/>}<br/></div></div><br/><strong>Flex框架中已经包含了这个方法 mx.utils.ObjectUtil.copy(value:Object):Object，直接使用即可。</strong><br/>]]></description>
		</item>
		
</channel>
</rss>
