Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
ActionScript3 における deep copyComments
schneemoca
follow
0
10-5-2009 6:06 PM
63 views
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Today's Top Clips
A Hostile Climate of Fear
pic of the day
Japanese Rice Field Art
50 Beautiful, Funny and Witty Photos
Liivng Root Bridges...
World's Smallest Orchid Discovered (By Accident)
The death of "wit"
Heavy Petting
What Cats Do When Left Home Alone
Flying Pigs
visit the
Top Clips page
View the Top Clips from
October 5, 2009
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/bbe65b20-8f3b-4d11-badd-3b038c76e07c/A54565E8-AF6E-439F-A5E5-A4F93FFA9A00/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://d.hatena.ne.jp/secondlife/20071127/1196123078" href="http://d.hatena.ne.jp/secondlife/20071127/1196123078" style="font-size: 11px;">d.hatena.ne.jp</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://d.hatena.ne.jp/secondlife/20071127/1196123078"><H3><A name="1196123078" href="http://d.hatena.ne.jp/secondlife/20071127/1196123078"><SPAN class="sanchor">■</SPAN></A>ActionScript3 における <A href="http://d.hatena.ne.jp/keyword/deep%20copy" class="keyword">deep copy</A><SPAN class="hatena-star-comment-container"><IMG src="http://s.hatena.ne.jp/images/comment.gif" tabindex="0" alt="Comments" title="Comments" class="hatena-star-comment-button" /></SPAN><SPAN class="hatena-star-star-container"><IMG src="http://s.hatena.ne.jp/images/add.gif" tabindex="0" alt="Add Star" title="Add Star" class="hatena-star-add-button" /><A href="http://s.hatena.ne.jp/koyhoge/"><IMG src="http://s.hatena.ne.jp/images/star.gif" tabindex="0" class="hatena-star-star" alt="koyhoge" title="" /></A><A href="http://s.hatena.ne.jp/octech/"><IMG src="http://s.hatena.ne.jp/images/star.gif" tabindex="0" class="hatena-star-star" alt="octech" title="" /></A><A href="http://s.hatena.ne.jp/Naski/"><IMG src="http://s.hatena.ne.jp/images/star.gif" tabindex="0" class="hatena-star-star" alt="Naski" title="" /></A><A href="http://s.hatena.ne.jp/naoto5959/"><IMG src="http://s.hatena.ne.jp/images/star.gif" tabindex="0" class="hatena-star-star" alt="naoto5959" title="" /></A><A href="http://s.hatena.ne.jp/everdibe/"><IMG src="http://s.hatena.ne.jp/images/star.gif" tabindex="0" class="hatena-star-star" alt="everdibe" title="" /></A></SPAN></H3></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://d.hatena.ne.jp/secondlife/20071127/1196123078"><PRE class="syntax-highlight"><SPAN class="synStatement">public</SPAN> <SPAN class="synStatement">static</SPAN> <SPAN class="synIdentifier">function</SPAN> clone(arg:*):* <SPAN class="synIdentifier">{</SPAN> <SPAN class="synIdentifier">var</SPAN> b:ByteArray = <SPAN class="synStatement">new</SPAN> ByteArray(); b.writeObject(arg); b.position = 0; <SPAN class="synStatement">return</SPAN> b.readObject(); <SPAN class="synIdentifier">}</SPAN> </PRE></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://d.hatena.ne.jp/secondlife/20071127/1196123078"><PRE class="syntax-highlight"><SPAN class="synIdentifier">var</SPAN> hash:<SPAN class="synType">Object</SPAN> = <SPAN class="synIdentifier">{</SPAN> ary: <SPAN class="synIdentifier">[</SPAN>0,1,2,3<SPAN class="synIdentifier">]</SPAN> <SPAN class="synIdentifier">}</SPAN>; <SPAN class="synIdentifier">var</SPAN> hashClone:<SPAN class="synType">Object</SPAN> = ObjectUtil.clone(hash); hash.ary<SPAN class="synIdentifier">[</SPAN>3<SPAN class="synIdentifier">]</SPAN> = <SPAN class="synConstant">'a'</SPAN>; hash; <SPAN class="synComment">// #<Object:{ary:0, 1, 2, a}></SPAN> hashClone; <SPAN class="synComment">// #<Object:{ary:0, 1, 2, 3}></SPAN> </PRE></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://d.hatena.ne.jp/secondlife/20071127/1196123078"><P>のやり方が一番楽で高速だと思います。一度 ByteArray で AMF にしてからその AMF を再度<A href="http://d.hatena.ne.jp/keyword/%a5%c7%a5%b3%a1%bc%a5%c9" class="keyword">デコード</A>するという。<A class="okeyword" href="http://subtech.g.hatena.ne.jp/keyword/Ruby">Ruby</A> での Marshal.load(Marshal.dump(obj)) の方法に似てますね。</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://d.hatena.ne.jp/secondlife/20071127/1196123078"><P>またこの方法だと、コア<A href="http://d.hatena.ne.jp/keyword/%a5%af%a5%e9%a5%b9" class="keyword">クラス</A>以外の<A href="http://d.hatena.ne.jp/keyword/%a5%aa%a5%d6%a5%b8%a5%a7%a5%af%a5%c8" class="keyword">オブジェクト</A>は public な<A href="http://d.hatena.ne.jp/keyword/%ca%d1%bf%f4" class="keyword">変数</A>(readonly な<A href="http://d.hatena.ne.jp/keyword/%ca%d1%bf%f4" class="keyword">変数</A>は無理?)だけを抽出して <A href="http://d.hatena.ne.jp/keyword/Object" class="keyword">Object</A> として取得できたりします。ので、とある<A href="http://d.hatena.ne.jp/keyword/%a5%a4%a5%f3%a5%b9%a5%bf%a5%f3%a5%b9" class="keyword">インスタンス</A>の状態を取得して後で復元なんかも割とこの方法でうまくいったりします。</P></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/A54565E8-AF6E-439F-A5E5-A4F93FFA9A00/blog/" title="blog or email this clip"><img src="http://content9.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
New from the makers of Clipmarks:
Amplify.com - Don't just share the news...Amplify it!
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Copyright
Privacy
EULA
OK