Re: [flexcoders] Change Object Reference
Hi, I would think that setting; vo = null; then vo = someNewObject would unlink the reference. OR vo = new Object(); then vo = someNewObject Peace, Mike On 6/3/07, Kevin [EMAIL PROTECTED] wrote: This may be a simple question, but it's stumping me. I have a component that contains a property (type object) that holds a reference to an VO on my model. How to I unlink that reference? For example, when I set the property: var vo : Object = model.someObject; I then do something like this: vo = someNewObject; This happens model.someObject get's set to someNewObject... This is not what I want. Therefore, I assume I have to unlink the reference of vo to model.someObject, before I give it another reference. How do I do that? Thanks, Kevin -- Teoti Graphix http://www.teotigraphix.com Blog - Flex2Components http://www.flex2components.com You can find more by solving the problem then by 'asking the question'.
Re: [flexcoders] Change Object Reference
Rather than just assigning the model.someObject directly to the vo object, you may first need to instantiate it with: var vo:Object = new Object(); The assign the model.someObject to it: vo = model.someObject; When you then assign a different object to it, it should leave model.someObject alone and just use the newly assigned object. Jurgen Kevin wrote: This may be a simple question, but it's stumping me. I have a component that contains a property (type object) that holds a reference to an VO on my model. How to I unlink that reference? For example, when I set the property: var vo : Object = model.someObject; I then do something like this: vo = someNewObject; This happens model.someObject get's set to someNewObject... This is not what I want. Therefore, I assume I have to unlink the reference of vo to model.someObject, before I give it another reference. How do I do that? Thanks, Kevin
Re: [flexcoders] Change Object Reference
thanks. I will try this and let you know if it works. - kevin On Jun 3, 2007, at 9:33 AM, Jurgen Beck wrote: Rather than just assigning the model.someObject directly to the vo object, you may first need to instantiate it with: var vo:Object = new Object(); The assign the model.someObject to it: vo = model.someObject; When you then assign a different object to it, it should leave model.someObject alone and just use the newly assigned object. Jurgen Kevin wrote: This may be a simple question, but it's stumping me. I have a component that contains a property (type object) that holds a reference to an VO on my model. How to I unlink that reference? For example, when I set the property: var vo : Object = model.someObject; I then do something like this: vo = someNewObject; This happens model.someObject get's set to someNewObject... This is not what I want. Therefore, I assume I have to unlink the reference of vo to model.someObject, before I give it another reference. How do I do that? Thanks, Kevin
Re: [flexcoders] Change Object Reference
i couldn't get either of these solutions to work. When I reset the vo variable to nul (or new Object), it still modifies the object on the model. I could be doing something wrong, but for now, i decided to instantiate an entirely new super class each time the vo changes. I'll look into this a little more and see if I can do what I want... thanks, Kevin On Jun 3, 2007, at 9:33 AM, Jurgen Beck wrote: Rather than just assigning the model.someObject directly to the vo object, you may first need to instantiate it with: var vo:Object = new Object(); The assign the model.someObject to it: vo = model.someObject; When you then assign a different object to it, it should leave model.someObject alone and just use the newly assigned object. Jurgen Kevin wrote: This may be a simple question, but it's stumping me. I have a component that contains a property (type object) that holds a reference to an VO on my model. How to I unlink that reference? For example, when I set the property: var vo : Object = model.someObject; I then do something like this: vo = someNewObject; This happens model.someObject get's set to someNewObject... This is not what I want. Therefore, I assume I have to unlink the reference of vo to model.someObject, before I give it another reference. How do I do that? Thanks, Kevin
Re: [flexcoders] Change Object Reference
Afaik this is not possible. I guess your example is incomplete, or ? Cheers, Ralf. On 6/3/07, Kevin [EMAIL PROTECTED] wrote: This may be a simple question, but it's stumping me. I have a component that contains a property (type object) that holds a reference to an VO on my model. How to I unlink that reference? For example, when I set the property: var vo : Object = model.someObject; I then do something like this: vo = someNewObject; This happens model.someObject get's set to someNewObject... This is not what I want. Therefore, I assume I have to unlink the reference of vo to model.someObject, before I give it another reference. How do I do that? Thanks, Kevin -- Ralf Bokelberg [EMAIL PROTECTED] Flex Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35
Re: [flexcoders] Change Object Reference
Hey Kevin, See if this makes sense in your configuration: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; creationComplete=initApp() layout=vertical mx:Script ![CDATA[ private var obj1:Object = new Object(); private var obj2:Object = new Object(); [Bindable] private var objRef:Object = new Object(); private function initApp():void { obj1.text = test1; obj2.text = test2; txtObject0.text = obj1.text; txtObject1.text = obj2.text; objRef = obj1; } private function switchObjects(event:Event):void { objRef = obj2; // testing reassigning of objects txtObject0.text = obj1.text; txtObject1.text = obj2.text; } ]] /mx:Script mx:Panel id=myPanel width=538 height=334 layout=absolute mx:VBox width=100% height=100% x=10 y=10 mx:Label text=VO Object/ mx:TextArea width=498 id=txtObject borderStyle=solid text={objRef.text}/ mx:Label text=someObject/ mx:TextArea width=498 id=txtObject0 borderStyle=solid/ mx:Label text=someNewObject/ mx:TextArea width=498 id=txtObject1 borderStyle=solid/ mx:Button click=switchObjects(event) label=Switch Objects/ /mx:VBox /mx:Panel /mx:Application You'll see objRef taking on the new object values and leaving obj1 alone when you switch object assignments. Jurgen Kevin wrote: i couldn't get either of these solutions to work. When I reset the vo variable to nul (or new Object), it still modifies the object on the model. I could be doing something wrong, but for now, i decided to instantiate an entirely new super class each time the vo changes. I'll look into this a little more and see if I can do what I want... thanks, Kevin On Jun 3, 2007, at 9:33 AM, Jurgen Beck wrote: Rather than just assigning the model.someObject directly to the vo object, you may first need to instantiate it with: var vo:Object = new Object(); The assign the model.someObject to it: vo = model.someObject; When you then assign a different object to it, it should leave model.someObject alone and just use the newly assigned object. Jurgen Kevin wrote: This may be a simple question, but it's stumping me. I have a component that contains a property (type object) that holds a reference to an VO on my model. How to I unlink that reference? For example, when I set the property: var vo : Object = model.someObject; I then do something like this: vo = someNewObject; This happens model.someObject get's set to someNewObject... This is not what I want. Therefore, I assume I have to unlink the reference of vo to model.someObject, before I give it another reference. How do I do that? Thanks, Kevin
RE: [flexcoders] Change Object Reference
Is it just me? References don't need unlinking. The original example should just work. Kevin, can you post your code so we can see what you're trying to do? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jurgen Beck Sent: Sunday, June 03, 2007 11:16 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Change Object Reference Hey Kevin, See if this makes sense in your configuration: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; http://www.adobe.com/2006/mxml creationComplete=initApp() layout=vertical mx:Script ![CDATA[ private var obj1:Object = new Object(); private var obj2:Object = new Object(); [Bindable] private var objRef:Object = new Object(); private function initApp():void { obj1.text = test1; obj2.text = test2; txtObject0.text = obj1.text; txtObject1.text = obj2.text; objRef = obj1; } private function switchObjects(event:Event):void { objRef = obj2; // testing reassigning of objects txtObject0.text = obj1.text; txtObject1.text = obj2.text; } ]] /mx:Script mx:Panel id=myPanel width=538 height=334 layout=absolute mx:VBox width=100% height=100% x=10 y=10 mx:Label text=VO Object/ mx:TextArea width=498 id=txtObject borderStyle=solid text={objRef.text}/ mx:Label text=someObject/ mx:TextArea width=498 id=txtObject0 borderStyle=solid/ mx:Label text=someNewObject/ mx:TextArea width=498 id=txtObject1 borderStyle=solid/ mx:Button click=switchObjects(event) label=Switch Objects/ /mx:VBox /mx:Panel /mx:Application You'll see objRef taking on the new object values and leaving obj1 alone when you switch object assignments. Jurgen Kevin wrote: i couldn't get either of these solutions to work. When I reset the vo variable to nul (or new Object), it still modifies the object on the model. I could be doing something wrong, but for now, i decided to instantiate an entirely new super class each time the vo changes. I'll look into this a little more and see if I can do what I want... thanks, Kevin On Jun 3, 2007, at 9:33 AM, Jurgen Beck wrote: Rather than just assigning the model.someObject directly to the vo object, you may first need to instantiate it with: var vo:Object = new Object(); The assign the model.someObject to it: vo = model.someObject; When you then assign a different object to it, it should leave model.someObject alone and just use the newly assigned object. Jurgen Kevin wrote: This may be a simple question, but it's stumping me. I have a component that contains a property (type object) that holds a reference to an VO on my model. How to I unlink that reference? For example, when I set the property: var vo : Object = model.someObject; I then do something like this: vo = someNewObject; This happens model.someObject get's set to someNewObject... This is not what I want. Therefore, I assume I have to unlink the reference of vo to model.someObject, before I give it another reference. How do I do that? Thanks, Kevin
Re: [flexcoders] Change Object Reference
No, you are not alone. Maybe the content of my email just didn't come across. Kevin, is your example code complete? r. On 6/3/07, Alex Harui [EMAIL PROTECTED] wrote: Is it just me? References don't need unlinking. The original example should just work. Kevin, can you post your code so we can see what you're trying to do?