I reported this to Adobe as a bug. Definitely report it on the bug/wish list so that this gets attention.
Here's my version: http://madebyderek.com/playground/extint/example2 In those two examples, pressing the button in the SWF creates an object and passes it to JavaScript via EI. The JavaScript function loops through the object displaying the contents. Pressing the button in the HTML page creates an object and passes it to the SWF via EI. The ActionScript loops through the object displaying the contents. As you can see if the SWF is version 8 everything is good. If the SWF is version 9, that's where the trouble is. The issue is that properties on a subobject are copied to the main object, whether there was a property with the same name or not on the main object. I'm actually pretty surprised this hasn't come up more often. I suppose people aren't passing around that much data, or data with subobjects very often ... or they just haven't noticed the problem yet. On 06 Mar 2007 13:30:11 -0800, gtuhl <[EMAIL PROTECTED]> wrote:
There is a typo in my post. The "control" property for subObject should be named "subObjectControl". The purpose of it was to have a differently named property to demonstrate that the issue is specific to same-named properties. Sorry about that, Joe --- In [email protected] <flexcoders%40yahoogroups.com>, "gtuhl" <[EMAIL PROTECTED]> wrote: > > I hope this isn't a bug and I am just doing something wrong. The > situation is we have an object that looks like this (JSON notation): > > <pre> > mainObject = { > id: "1234", > name: "mainObject Name", > control: "mainObject Control", > subObject: { > id: "abcd", > name: "subObject Name", > control: "subObject Control" > } > } > </pre> > > That is we have an object with a property that is another object type > and both objects share some property names. > > When we route something like this through ExternalInterface I can > verify the object is exactly as described above using Firebug on the > JS side and remains that way right up through completion of the > ExternalInterface call. > > Then immediately upon this object's arrival on the actionscript3 end > it looks like this: > > <pre> > mainObject = { > id: "abcd", > name: "subObject Name", > control: "mainObject Control", > subObject: { > id: "abcd", > name: "subObject Name", > control: "subObject Control" > } > } > </pre> > > The value of the same-named properties were all set to the values > found on the "subObject". It seems like there is some buggy > underlying implementation detail in ExternalInterface related to > maintenance of property names and values. > > Has anyone else had this problem before? I am hoping we are just > doing something wrong, but I am out of code I can run a debugger on > (the corruption of property values is happening in core > ExternalInterface code). I can verify the above quite explicitly by > debugging with Firebug and FlexBuilder on the two ends of the call. > > The Flex-Ajax bridge seems buggy and if it uses ExternalInterface > internally I imagine it would have the same problems. If we can't > figure this out we'll either need to build our own JSON > serialization/deserialization libraries or switch tech. If Flex had > an eval capability deserializing JSON strings would be trivial but > unfortunately that method doesn't appear to be available. > > Really appreciate any assistance, would be happy to provide additional > details if they are necessary. If this is a bug, how have others > gotten past it through workarounds? > > Joe >
-- Derek Vadneau

