ObjectUtil.copy() and Dictionaries

View: New views
4 Messages — Rating Filter:   Alert me  

ObjectUtil.copy() and Dictionaries

by seanmcmonahan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have an AIR project setup in Flex Builder 3 that copies a subclass of flash.utils.Dictionary just fine with ObjectUtil.copy() when the target player is set to 9.0.28.  However, when the target player is set to 10.0.0 I get the following error when attempting to make a copy:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.utils::Dictionary@2743cf71 to com.elasticsales.utils.ElasticDictionary.

Does any one have any insight into why this is happening?  


RE: ObjectUtil.copy() and Dictionaries

by Alex Harui :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Might be a bug.  Not sure they expected Dictionary to be serialized.  You might have to write your own copy function.

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: flexcoders@... [mailto:flexcoders@...] On Behalf Of seanmcmonahan
Sent: Thursday, November 05, 2009 1:49 PM
To: flexcoders@...
Subject: [flexcoders] ObjectUtil.copy() and Dictionaries



I have an AIR project setup in Flex Builder 3 that copies a subclass of flash.utils.Dictionary just fine with ObjectUtil.copy() when the target player is set to 9.0.28. However, when the target player is set to 10.0.0 I get the following error when attempting to make a copy:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.utils::Dictionary@2743cf71 to com.elasticsales.utils.ElasticDictionary.

Does any one have any insight into why this is happening?


Re: ObjectUtil.copy() and Dictionaries

by seanmcmonahan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the reply, Alex.  Should I submit a bug report for Flash Player 10/AIR?

From what I've read Dictionary is not really meant to be serialized but you can get around it by using the RemoteClass metadata tag and by implementing IExternalizable, both of which I've done.  

My understanding is the any class that implements IExternalizable should use the writeExternal and readExternal methods when the object is being serialized but that's not happening in my case.  

Also, I'm not directly serializing the Dictionary, it's a property of another object.  So while writing a custom copy function is not a big deal I need a way for it to be called when the parent object is serialized.  Any thoughts?  The app that's using these Dictionaries relies on them heavily so dumping them in favor of something else isn't really an option.



--- In flexcoders@..., Alex Harui <aharui@...> wrote:

>
> Might be a bug.  Not sure they expected Dictionary to be serialized.  You might have to write your own copy function.
>
> Alex Harui
> Flex SDK Developer
> Adobe Systems Inc.<http://www.adobe.com/>
> Blog: http://blogs.adobe.com/aharui
>
> From: flexcoders@... [mailto:flexcoders@...] On Behalf Of seanmcmonahan
> Sent: Thursday, November 05, 2009 1:49 PM
> To: flexcoders@...
> Subject: [flexcoders] ObjectUtil.copy() and Dictionaries
>
>
>
> I have an AIR project setup in Flex Builder 3 that copies a subclass of flash.utils.Dictionary just fine with ObjectUtil.copy() when the target player is set to 9.0.28. However, when the target player is set to 10.0.0 I get the following error when attempting to make a copy:
>
> TypeError: Error #1034: Type Coercion failed: cannot convert flash.utils::Dictionary@2743cf71 to com.elasticsales.utils.ElasticDictionary.
>
> Does any one have any insight into why this is happening?
>



RE: Re: ObjectUtil.copy() and Dictionaries

by Alex Harui :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd file a bug.  Not sure if they'll fix it any time soon though.

If you own the object that references the dictionaries, you should be able to code your own writeExternal/readExternal and encode the dictionaries in some way.

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: flexcoders@... [mailto:flexcoders@...] On Behalf Of seanmcmonahan
Sent: Friday, November 06, 2009 9:59 AM
To: flexcoders@...
Subject: [flexcoders] Re: ObjectUtil.copy() and Dictionaries



Thanks for the reply, Alex. Should I submit a bug report for Flash Player 10/AIR?

From what I've read Dictionary is not really meant to be serialized but you can get around it by using the RemoteClass metadata tag and by implementing IExternalizable, both of which I've done.

My understanding is the any class that implements IExternalizable should use the writeExternal and readExternal methods when the object is being serialized but that's not happening in my case.

Also, I'm not directly serializing the Dictionary, it's a property of another object. So while writing a custom copy function is not a big deal I need a way for it to be called when the parent object is serialized. Any thoughts? The app that's using these Dictionaries relies on them heavily so dumping them in favor of something else isn't really an option.

--- In flexcoders@...<mailto:flexcoders%40yahoogroups.com>, Alex Harui <aharui@...> wrote:

>
> Might be a bug. Not sure they expected Dictionary to be serialized. You might have to write your own copy function.
>
> Alex Harui
> Flex SDK Developer
> Adobe Systems Inc.<http://www.adobe.com/>
> Blog: http://blogs.adobe.com/aharui
>
> From: flexcoders@...<mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@...<mailto:flexcoders%40yahoogroups.com>] On Behalf Of seanmcmonahan
> Sent: Thursday, November 05, 2009 1:49 PM
> To: flexcoders@...<mailto:flexcoders%40yahoogroups.com>
> Subject: [flexcoders] ObjectUtil.copy() and Dictionaries
>
>
>
> I have an AIR project setup in Flex Builder 3 that copies a subclass of flash.utils.Dictionary just fine with ObjectUtil.copy() when the target player is set to 9.0.28. However, when the target player is set to 10.0.0 I get the following error when attempting to make a copy:
>
> TypeError: Error #1034: Type Coercion failed: cannot convert flash.utils::Dictionary@2743cf71 to com.elasticsales.utils.ElasticDictionary.
>
> Does any one have any insight into why this is happening?
>