PDA

View Full Version : SharedObect flush fails (Flash Lite 2.0)


can16358p
02-19-2006, 10:00 AM
First of all I want to say I couldn't find a place to post this and I don't know if it's the right place to post it here, if it's wrong, please move it to the correct place.

I have a weird problem with SharedObjects in Flash Lite 2.0

I know that it works different from the one on PC, and I read articles about it and wrote my code.

Here's the code from the dice throwing game I've been working on, it should be right according to the articles on the Internet:


function save() {
_root.so.data.luck = luck;
_root.so.data.skill = skill;
_root.so.data.cheat = cheat;
_root.so.data.money = money;
_root.so.data.bank = bank;
_root.so.data.credits = credits;
_root.so.flush();
}
function loadednow(so:SharedObject) {
trace(so.getSize());
if (so.data.created == "yes") {
trace("a");
_root.luck = so.data.luck;
_root.skill = so.data.skill;
_root.cheat = so.data.cheat;
_root.money = so.data.money;
_root.bank = so.data.bank;
_root.credits = so.data.credits;
} else {
trace("b");
so.data.created = "yes";
_root.luck = Number(50);
_root.skill = Number(50);
_root.cheat = Number(50);
_root.money = Number(1000);
_root.bank = Number(1000);
_root.credits = Number(0);
}
save();
}
SharedObject.addListener("the_gamble", loadednow);
var so:SharedObject = SharedObject.getLocal("the_gamble");



just at the beginning of loadednow, I see 0 in the output for "trace(so.getSize());". That's true, there's no actual file for the shared object, never. I also always get traced "b", never "a". Thought there may be a problem with save() function I've written and tried so.flush() in lots of places, still no change. Then, I've added a status handler (onStatus) for so and realized that it always returned false (Flush.Failed). Why can this be? No problem with FP8 and movies made for it, but this one won't work. Is there a problem with my code or settings or anything else? (no problem with settings about allocating space for the so's, as I said fp8 and so's work perfectly.)