PDA

View Full Version : [AS3] saving a map to reload later 2d array


werl
01-03-2011, 01:46 AM
I have a game where you build stuff onto a grid and I need to be able to save and load the grid. All points are movcieclips and will have quite a few different frames.

Thanks, if you need any more info don't hesitate to ask.

zyxstand
01-03-2011, 07:21 AM
you can't save things to the hard drive with flash. you can create cookie-like things called sharedobject (you can look into that).
if you need it temporarily or something, what you could do is have the program spit out some formatted text that you can copy and save somewhere, and next time you run your flash file you can either just paste it or url-load it.
there are plenty of sharedobject tutorials out there if you wanna do that. note that these "cookies" are not 100% reliable. they will be cleared when you clear your cache for instance.

werl
01-03-2011, 10:14 PM
This is to be kept inside the running file, the big thing is to set it up so that when you go to another frame then come back it will be the same.

rrh
01-05-2011, 04:45 PM
Oh, then the big issue isn't where you're storing the data: you're just sticking it in variables. The big issue is how to organize and process all that data.

So you're saying what you need to store for each movieclip is x, y and frame?

werl
01-05-2011, 10:40 PM
Yes.

I have a new different problem, when I click on a movieclip I need to add 1 to a var, but bore some reason it's not working. This code is in an .as file and everything else is working fine. Here is the code:


var foodland:int;
function funct1(Event:MouseEvent):void{
foodland ++;
this.play();
}

and then the following is on the mc

this.addEventListener(MouseEvent.CLICK, funct1);