mx.utils.ObjectUtil. ________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Kevin Sent: Monday, March 26, 2007 11:52 AM To: [email protected] Subject: Re: [flexcoders] Two-Way Binding Solutions? i think my problem boils down to one of object cloning. Does anyone have a good solution for deep cloning objects in AS3? Seems like this would be a pretty useful utility. - Kevin On Mar 26, 2007, at 1:50 PM, Kevin wrote: I have trying to figure out how best to accomplish the two-way data binding needed for form entry. Here is what I thought would work, but it doesn't seem to: ON MODEL: I created two variables that hold my VO. model.pendingContact model.newContact The user clicks a button to get ContactVO data from the server. In the command class I assign the result (which is a typed PHP ContactVO) to each variable: model.pendingContact = data.result; model.newContact = data.result; I then bind my form fields to "model.pendingContact" so that the existing values from the server show up in the TextInput fields. Lastly, I use the BindingUtil methods to bind the "text" property of the TextInput fields back to "model.newContact" so that I can record any changes and send them back to the server. When the user submits the form, "model.pendingContact" should hold the old values & "model.newContact" should have the new values. Correct?? Am I overlooking something. The only way I can get this to work is if I don't assign "model.newContact" to the values from the server and instead create a new instance like this: model.pendingContact = data.result; model.newContact = new ContactVO; However, I can't do this because I need the newContact to start out with the old values from the server. Is there a duplicate or clone object method that I need to use so that both model variables can be assigned to the same object from the server?? Thanks for the help. - Kevin

