问题描述
我在执行剪切复制粘贴在我的应用程序,如 cacoo 。但我这些操作过程中遇到的问题。我使用的背后剪切复制粘贴的想法
I am implementing Cut Copy Paste in my application like cacoo. but I face problem during these operation.i'm using idea behind cut copy paste
var className:String = getQualifiedClassName(objcut.getItemAt(i))
var klass:Class = getDefinitionByName(className) as Class
var cloneObject:* = new klass()
所以我不能够preserve对象的所有属性。还有就是执行柔性4.how这些操作我可以复制的Flex 4(AS3)的图形对象中的任何其他的想法。复制对象并粘贴多次。
so i'm not able to preserve all property of object.There is any other idea to perform these operation in flex 4.how can i copy an Graphical object in Flex 4(as3). Copy an Object and paste multiple times.
推荐答案
以与性能对象的副本,最简单的方法是使用的ByteArray:
The simplest way to make a copy of object with properties is using ByteArray:
public static function copy(value:Object):Object
{
if (!value)
return null;
//register object class to prevent Error #1034: Type Coercion failed
registerClassAlias(getQualifiedClassName(value), value.constructor);
var buffer:ByteArray = new ByteArray();
buffer.writeObject(value);
buffer.position = 0;
var result:Object = buffer.readObject();
return result;
}
但你仍然可以得到错误#1034嵌套类。您需要注册别名所有嵌套类prevent此之前,一些启动方法制作副本,例如。
But you can still get the error #1034 for nested classes. You need register aliases for all nested classes to prevent this before making copy, for example in some startup method.
这篇关于剪切复制粘贴用的DisplayObject(集团UIComponent)的动作脚本3柔性4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!