SharedObject#size reports different values Flash vs HTML5

Hi. I’ve been doing some tests with SharedObject#size and it seems that for an newly created SharedObject instance, size reports different values in Flash and HTML5.

The relevant code is:

var so = SharedObject.getLocal("SharedObjectTest");
trace(so.size);

In Flash, it prints 0. In HTML5, it prints 2.

Back in the old Flash days, I’ve used (and seen used) checks like (so.size == 0) for simple detection of a new user of the application.

Thanks for looking into this.

You can check the existence of so.data so you don’t have to rely on size

no, it doesn’t work, so.data is never null. you can check in openfl.net, SharedObject.hx the implementation of SharedObject#getLocal does this:

sharedObject.data = {};

but anything you put in data is null. come on now :smiley:

settings = so.data.settings;
if ( settings == null ) {
//voila
}

sure, that works or, if you store directly in data atomic types:

someField = Reflect.hasField(so.data, "someFieldName") ? so.data.someFieldName : aDefaultAtomicValue;

was just trying to point out a possible back compatibility issue.

thanks, sounds like this is something we should improve:

Perhaps we could hard-code a -2 in there (if we are bold) or do a null check, I agree we should return 0 as expected