issues with local SharedObject

13 views
Skip to first unread message

Vijay Khambalkar

unread,
Jul 17, 2007, 1:04:40 AM7/17/07
to flex_...@googlegroups.com
Hi all,
I am facing issues with local SharedObject. I have code like this
 
loginDetails = SharedObject.getLocal("loginDetails");
var voUser:UserVO;
loginDetails.data.loginDetails = voUser;
 
I am storing the UserVO object into the data property of SharedObject. But when I tried it to get it back from the property in the following way
 
var newVOUser:UserVO = UserVO(loginDetails.data.loginDetails);
 
Its giving me the typecasting error. Why? any workaround to this problem?
 
Thanks in advance
Vijay Khambalkar

karan

unread,
Jul 17, 2007, 3:31:10 AM7/17/07
to flex_...@googlegroups.com
Did you try this one
var newVOUser:UserVO = loginDetails.data.loginDetails as UserVO;
--
regards
karan
mindrulers.blogspot.com

Abdul Qabiz

unread,
Jul 17, 2007, 7:23:22 AM7/17/07
to flex_...@googlegroups.com
Hi,

If you try to serialize a custom-class-instance to SharedObject, it is serialized as AMF. Type information is lost so while retrieving the object it is returned as Anonymous Object. To allow SharedObject return object as instance of a class, you need to register the class-alias using flash.net.registerClassAlias (..).  This API was known as Object.registerClass (..) in AS2.

registerClassAlias (..) - http://livedocs.adobe.com/flex/201/langref/flash/net/package.html#registerClassAlias()


I searched to see if someone has used before writing some code, I found an entry on Tushar's blog:-

http://tush.wordpress.com/2007/07/08/actionscript-3-serializing-classes-using-registerclassalias/

-abdul








Vijay

unread,
Jul 17, 2007, 11:58:13 PM7/17/07
to Flex India Community
Thanks alot, It solved my problem, registerClassAlias(aliasName,
class) Where aliasName is the object where we are holding this
property. :)

On Jul 17, 4:23 pm, "Abdul Qabiz" <abdul.qa...@gmail.com> wrote:
> Hi,
>
> If you try to serialize a custom-class-instance to SharedObject, it is
> serialized as AMF. Type information is lost so while retrieving the object
> it is returned as Anonymous Object. To allow SharedObject return object as
> instance of a class, you need to register the class-alias using
> flash.net.registerClassAlias (..). This API was known as
> Object.registerClass (..) in AS2.
>

> registerClassAlias (..) -http://livedocs.adobe.com/flex/201/langref/flash/net/package.html#reg...()


>
> I searched to see if someone has used before writing some code, I found an
> entry on Tushar's blog:-
>

> http://tush.wordpress.com/2007/07/08/actionscript-3-serializing-class...
>
> -abdul


>
> On 7/17/07, karan <karan.pra...@gmail.com> wrote:
>
>
>
>
>
> > Did you try this one
> > var newVOUser:UserVO = loginDetails.data.loginDetails as UserVO;
>

> > On 7/17/07, Vijay Khambalkar < vkhambal...@gmail.com> wrote:
>
> > > Hi all,
> > > I am facing issues with local SharedObject. I have code like this
>
> > > loginDetails = SharedObject.getLocal("loginDetails");
> > > var voUser:UserVO;
> > > loginDetails.data.loginDetails = voUser;
>
> > > I am storing the UserVO object into the data property of SharedObject.
> > > But when I tried it to get it back from the property in the following way
>
> > > var newVOUser:UserVO = UserVO(loginDetails.data.loginDetails);
>
> > > Its giving me the typecasting error. Why? any workaround to this
> > > problem?
>
> > > Thanks in advance
> > > Vijay Khambalkar
>
> > --
> > regards
> > karan

> > mindrulers.blogspot.com- Hide quoted text -
>
> - Show quoted text -

Reply all
Reply to author
Forward
0 new messages