flex - how to clone UIComponents added dynamically in a Canvas -
i facing issue in cloning of uicomponents added dynamically in canvas canvas.
i follow example doesn't work components added dynamically because childdescriptors become null in senario.
<?xml version="1.0" encoding="utf-8"?> <mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"> <mx:script> <![cdata[ private function clonebutton_clickhandler (event:mouseevent):void { var childdescriptors:array = original.childdescriptors; var descriptorscount:int = childdescriptors.length; (var i:int; < descriptorscount; i++) { cloned.createcomponentfromdescriptor(original.childdescriptors[i], false); } cloned.validatenow(); } ]]> </mx:script> <mx:button label="clone canvas" click="clonebutton_clickhandler(event);" /> <mx:canvas id="original" width="100" height="100" borderstyle="solid" > <mx:label text="some label" /> <mx:combobox dataprovider="{['data1', 'data2']}" bottom="0" /> </mx:canvas> <mx:canvas id="cloned" width="100" height="100" borderstyle="solid" > </mx:canvas> </mx:application>
i've never cloned objects childdescriptors might try cloning before descriptors set null, or @ least copying descriptors before that.
the descriptors set null part of process of instantiating mxml objects. should able the descriptors before happens.
try using "initialize" or "preinitialize" event dispatched object wish clone children of.
Comments
Post a Comment