One approach would be to use a proxy for the actual object and only use 
references to that on the client side, basically adding a layer in front 
of the object itself.

The other code that references the object will only ever deal with the 
proxy which can delegate calls to the real object.

You can use the __resolve method to trap any method calls or property 
accesses to the object and pass them along automatically, or you could 
of course implement the interface of Object A in the proxy explicitly.

Heres the doc reference for __resolve

http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001622.html

hope that gives you an avenue of hope :)

thanks,

Martin


Jim Laing wrote:
> Hello all,
> 
> If someone can figure this out, it'd make my day. Here's what we'd like to do:
> 
> We have an object A, which is an ActionScript object created on the
> client. In our application, we have at least two references to object
> A. Using one of the references, we send object A back to the middle
> tier, where it is serialized into a Java object, some operations are
> done (persistence related, like inserting into a DB and assigning a
> primary key), and object A is sent back to the client as object B,
> possibly with updates. When we receive it, we'd like to replace object
> A with object B. That is, we'd like to have all the former references
> to object A now point to object B. Since we only know about one of the
> references to object A, we want to use that reference to get all the
> references to object A and update them accordingly. So, in made up
> code, that would look something like this:
> 
> function updateReferences( refToA : Object, refToB : Object) {
>          var allRefsToA  : Array = refToA.getAllReferencesToObject(); 
> // made-up part
>          for(var i = 0; i < allRefsToA.length; i++) {
>                allRefsToA[i] = refToB;
>          }
> }
> 
> Does that make sense? Is there anything which we can do to simulate
> the imaginary "getAllReferencesToObject" function?
> 
> -------------------------------------------------------------------------------
> 
> (The rest is just explanation as to why we're not taking an
> alternative approach)
> 
> The reason why we want to do this, instead of simply copy all the
> attributes out of object B and into object A, is because the object
> heirarchy contains internal references back to the object which are
> necessary for our persistence layer to figure our the proper
> relationships. That is, our object A represents the parent in a
> parent-child relationship and each child contains a references back to
> the parent. Here's an ASCII representation (omitting the
> non-problematic attributes of A):
> 
>  A
>   |
> anArrayOfAChildren
> |         |         |
> cA1   cA2   cA3
> |         |         |
> A       A        A
> 
> And object B is essentially a copy of this object model, but with B's
> instead of A's. What we have done in the past (and recently discovered
> to be incorrect) is something like
> 
> function mergePersistenceChanges ( refToA : Object, refToB : Object) {
>       for(var i in refToB) {
>             refToA[i] = refToB[i];
>       }
> }
> 
> Which produces mostly what we want (all of the updated information is
> copied correctly), but in the case of our back-references, it produces
> an incorrect result like this:
> 
>  A
>   |
> anArrayOfBChildren
> |         |         |
> cB1  cB2    cB3
> |         |         |
> B       B        B
> 
> This causes future updates of attributes in object A not to be
> reflected in the childrean objects .... which is our problem. Is
> someone is able to suggest a solution, or a way to implement the
> proposed solution above? Thanks so much.
> 
> Jim
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 

-- 
Martin Wood

http://relivethefuture.com/choronzon


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/2jUsvC/tzNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to