AS3复制对象

编程入门 行业动态 更新时间:2024-10-28 12:19:36
本文介绍了AS3复制对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有时我们需要克隆object.but如果一个DisplayObject有一些孩子,并使用该函数是这样的:

sometimes we need clone a object.but if a displayObject has some children and use the function like this:

function clone(source:*):* { var b:ByteArray = new ByteArray(); b.writeObject(source); b.position = 0; return(b.readObject()); }

但结果一直没有孩子.. ..。所以我应该怎么办?

but the result has no children.. .. . so what should I do ?

推荐答案

我没有编写一个克隆的方法我自己,但我发现,可能做的伎俩的方式。通过所有的变量迭代(在一个XML-RE presentation),你可以把它们复制在你的类的新实例。

I didn't have to program a clone-method myself yet, but i found a way that might do the trick. By iterating through all your variables (in an xml-representation), you can copy them in a new instance of your class.

您可以找到方法,我这个环节上谈到:的www.learnosity/techblog/index.cfm/2008/2/6/AS3--Looping-over-properties-of-a-class

you can find the method i am talking about on this link: www.learnosity/techblog/index.cfm/2008/2/6/AS3--Looping-over-properties-of-a-class

让我知道,如果它的工作原理,我有点好奇自己:)

Let me know if it works, i'm kind of curious myself :)

更多推荐

AS3复制对象

本文发布于:2023-11-23 15:14:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621903.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!