Dwedit's Board

Enjoy the board

You are not logged in.

Announcement

User passwords may have been corrupted, if you can't log in, use the "Forgot Password" feature. If you still can't log in, contact me and I can try to manually reset your password.

#1 2009-03-28 8:50:18 am

Dwedit
Administrator
From: Chicago
Registered: 2004-12-12
Posts: 1,017
Website

Flash Shared Objects 101

Flash Shared Objects 101:

When making a flash save game, NEVER do this:
mySO = SharedObject.getLocal('Foo');
mySO.data.some_array=some_array;

If you do, the shared object contains a REFERENCE to the array, and the shared object will change as the game changes the array.  So you go save your game, run the game, then some stuff that happened in your game now sticks in the savefile even though you didn't save again.

Instead do this:

	function copy_object(src)
	{
		if (typeof(src)!="object")
		{
			return src;
		}
		var dest=new src.__proto__.constructor();
		for (var v in src)
		{
			dest[v]=copy_object(src[v]);
		}
		return dest;
	}

then use it like this:
mySO = SharedObject.getLocal('Foo');
mySO.data.some_array=copy_object(some_array);

No matter what type you are using, it will save it correctly.

This is for Ationscript 1.x and 2.x, not sure about behavior for AS3.


"We are merely sprites that dance at the beck and call of our button pressing overlord."

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman