克隆Flex组件 [英] clone flex component

查看:124
本文介绍了克隆Flex组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿 我试图复制一个Flex组件在运行时。

Hey I am trying to duplicate a flex component at run time.

例如,如果我有这样的

MX:按钮标签=BTNID =BTN点击=handleClick(事件)/>

mx:Button label="btn" id="btn" click="handleClick(event)"/>

我应该能够调用一个名为DuplicateComponent(功能),它应该返回我一个UI组件thts完全相同上述按钮,包括事件侦听器。

i should be able to call a function called DuplicateComponent() and it should return me a UI component thts exactly same as above button including the event listeners with it.

能有一个人帮我请? 在此先感谢

Can some one help me please?? Thanks in advance

推荐答案

做一个字节数组复制。这code段应该为你做它:

Do a Byte Array Copy. This code segment should do it for you:

// ActionScript file
import flash.utils.ByteArray;

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

一注,我没有写这个$ C C $我自己,我是pretty的肯定,我从Flex codeR名单上后下了。

One note, I did not write this code myself, I'm pretty sure I got it from a post on the Flex Coder's list.

这篇关于克隆Flex组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆