Expand my Community achievements bar.

SOLVED

How to cast items in a sharedCollection

Avatar

Level 1

Hi,

i’m testing LCCS for my new app and I have a problem using a SharedCollection:

i’m adding to it custom objects and when i get it, i’m unable to cast them. I receive an "Object" typed object and so i can’t use it.

I know I should use [RemoteClass] metatag but it’s not working too.

Any idea?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi Raphi,

You might have to explore MessageItem.registerBodyClass API, and also you could check out one of our sample apps that demonstrates how to use the API.

The app could be found in your SDKPath/sampleApps/ComplexObjectTransfer

Thanks

Arun

View solution in original post

4 Replies

Avatar

Correct answer by
Employee

Hi Raphi,

You might have to explore MessageItem.registerBodyClass API, and also you could check out one of our sample apps that demonstrates how to use the API.

The app could be found in your SDKPath/sampleApps/ComplexObjectTransfer

Thanks

Arun

Avatar

Level 1

Hi aponnusa,

thanks to MessageItem.registerBodyClass, it's now working !

But I found a strange behaviour / bug :

it's impossible to serialize objects that have a constructor with parameters??

With this object, it doesnt work:

public function VideoVO(author:String, lat:Number, lng:Number)

{

     this.author = author;

     this.lat = lat;

     this.lng = lng;

}

But with an empty parameters constructor, everything's fine !

Is that a bug?

Thanks for your help.

Avatar

Former Community Member

Ah, this one's a classic AS/Flash Player issue. The AMF serialization

format doesn't provide for classes with required params in the constructor.

To have the best of both worlds, you can make your constructors params

optional with VideoVO(author:String=null, lat:Number = 0,

lng:Number=0):void.

The good news is that any public member variables will be stored at

serialization and applied to the class on deserialization.

hope that helps,

nigel

Avatar

Level 1

Ok i didn't know that.

Thanks for the tip !