Hi All, Does anyone have idea about creating clone for a display object. I read about ObjectUtil.copy and byteArray technique, but these do not work for display objects.
I am facing this issue in displaying a component in popup, making some changes in contents, and on cancel button click I do not wish to save the changes. Please refer below code: TestApplication.mxml <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.managers.PopUpManager; private var testComp:TestComp = new TestComp(); private function btnClickHandler():void { var testComp1:TestComp = new TestComp(); testComp1= testComp; testComp1.addEventListener("closePopup",removePopupFromdiaplyList); PopUpManager.addPopUp(testComp1,this,true); } private function removePopupFromdiaplyList(event:Event):void { PopUpManager.removePopUp(event.target as TestComp); } private function clone(source:TestComp):TestComp { var copier:ByteArray = new ByteArray(); copier.writeObject(source); copier.position = 0; return(copier.readObject() as TestComp); } ]]> </mx:Script> <mx:Button label="displayPopup" click="btnClickHandler()" /> </mx:Application> TestComp: <?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" showCloseButton="true" close="dispatchCloseEvent()" > <mx:Metadata> [Event(name="closePopup", type="flash.events.Event")] </mx:Metadata> <mx:Script> <![CDATA[ import mx.managers.PopUpManager; private function dispatchCloseEvent():void { this.dispatchEvent(new Event("closePopup")); } ]]> </mx:Script> <mx:VBox> <mx:TextArea width="100" height="100"/> </mx:VBox> </mx:TitleWindow> Please share you knowledge on cloning a display object. Thanks in advance! Regards, Shalu -- You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.

