00:00
00:00
Newgrounds Background Image Theme

KungFuCarafu just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS: Save and Load

37,821 Views | 127 Replies
New Topic Respond to this Topic

Response to AS: Save and Load 2007-04-23 18:12:27


I found this in the Sample files in the Flash 8 folder...

import mx.controls.*;
var status_lbl:Label;
var username_ti:TextInput;
var password_ti:TextInput;
password_ti.password = true;
submit_btn.clickHandler = function() {
checkForm();
};
var formListener:Object = new Object();
formListener.enter = function(evt) {
checkForm();
};
username_ti.addEventListener("enter", formListener);
password_ti.addEventListener("enter", formListener);
Selection.setFocus(username_ti);
function checkForm() {
if (username_ti.text.length == 0) {
status_lbl.text = "<font color=\"#EFDFDC\">Please enter user name.</font>";
Selection.setFocus(username_ti);
return false;
}
if (password_ti.text.length == 0) {
status_lbl.text = "<font color=\"#EFDFDC\">Please enter password.</font>";
Selection.setFocus(password_ti);
return false;
}
status_lbl.text = "";
var result_lv:LoadVars = new LoadVars();
var login_lv:LoadVars = new LoadVars();
login_lv.username = username_ti.text;
login_lv.password = password_ti.text;
login_lv.sendAndLoad("http://www.flash-mx.com /mm/login.cfm", result_lv, "POST");
result_lv.onLoad = function(success:Boolean) {
if (success) {
if (this.isValidLogin == 1) {
status_lbl.text = "<font color=\"#009900\">login successful.</font>";
} else {
status_lbl.text = "<font color=\"#EFDFDC\">invalid user name / password.</font>";
Selection.setFocus(username_ti);
Selection.setSelection(0, username_ti.text.length);
}
} else {
status_lbl.text = "Unable to connect to login URL";
username_ti.enabled = false;
password_ti.enabled = false;
submit_btn.enabled = false;
}
};
return true;
}

I took out all of the comments.That would be nice if someone could explain this this code,because I'm sure a lot of people would like to use a script like this,but also know how it works and such.

Yes,you'll need a server or something...


wat

Response to AS: Save and Load 2007-06-04 01:57:06


Is there are way you tell it to save all the variables and load in the variables in the right places?

Response to AS: Save and Load 2007-06-22 10:49:37


Can arrays be saved? My game doesnt seem to want to save and load arrays... unless I'm just doing it wrong.


...

BBS Signature

Response to AS: Save and Load 2007-06-24 15:36:10


I still can't understand of this. Can someone give me download a .fla file?

Response to AS: Save and Load 2007-06-30 14:20:41


Hmph i think there should be a little more attention to the AS3:main thread cuz lets face it in an year will all have to use AS3 to keep up with the trend


BBS Signature

Response to AS: Save and Load 2007-07-21 10:38:37


My save button doesn't work well.
Save:
on (press) {
savefile.data.Num1 = _root.Num1;
savefile.flush();
}

Load:
on (press) {
var savefile = SharedObject.getLocal("Character2DCreato r");
if (savefile.data.Num1 == undefined) {
_root.Num1 = 6;
} else {
_root.Num1 = savefile.data.Num1;
}
}

Some info: Flash 8, AS2, Windows Vista.
What am I doing wrong?

Response to AS: Save and Load 2007-07-21 10:44:53


Name of the cookies have to match.

Response to AS: Save and Load 2007-07-21 11:28:30


At 7/21/07 10:44 AM, Deathcon7 wrote: Name of the cookies have to match.

Is this what you mean?

Save:
on (press) {
Character2DCreator.data.Num1 = _root.Num1;
Character2DCreator.flush();
}

Load:
on (press) {
var Character2DCreator = SharedObject.getLocal("Character2DCreato r");
if (Character2DCreator.data.Num1 == undefined) {
_root.Num1 = 6;
} else {
_root.Num1 = Character2DCreator.data.Num1;
}
}

Response to AS: Save and Load 2007-10-30 22:05:34


Hi, I know that on WinXP, the save files can be found at:
C:/Documents and Settings/Username/Application Data (hidden)/Macromedia/Flash Player/

but does anyone know where they can be found on a Mac? (someone playing our game on a Mac needs to retrieve his save files)

Thanks.


Castle is now available on Steam!

BBS Signature

Response to AS: Save and Load 2007-12-12 19:49:19


I read the tut and I put this script on the save button
on (press){
savefile.data.lvl=_root.lvl;
savefile.data.xp=_root.xp;
savefile.data.gold=_root.gold;
savefile.data.health=_root.health;
savefile.data.hp=_root.hp;
savefile.data.mp=_root.mp;
savefile.data.power=_root.power;
savefile.flush();
}
And this on the load button (They are buttons not MC's)
on(press){
var savefile = SharedObject.getLocal("My Rpg");
if(savefile.data.score==undefined){
_root.lvl=0;
_root.power=0;
_root.mp=0;
_root.hp=0;
_root.health=0;
_root.gold=0;
_root.xp=0;
}else{
_root.health=savefile.data.health;
_root.lvl=savefile.data.lvl;
_root.mp=savefile.data.mp;
_root.hp=savefile.data.hp;
_root.lvl=savefile.data.lvl;
_root.xp=savefile.data.xp;
_root.gold=savefile.data.gold;
_root.power=savefile.data.power;
}
}
And the problem is:
1.) I cant find the save data in "C:\Documents and Settings\_-_-_-\Application Data\Macromedia\Flash Player\#SharedObjects\4P3SQ7QQ"
2.) I check the syntax and its says its 100% ok and there is no problems with it ( For both buttons)
And
3.) When I load it my stats go to "0".(Which I am guessing is because the variable on the load button.)
Can some one help me out please Im not sure where I have screwed up.

Response to AS: Save and Load 2008-01-02 18:13:38


Omg! This is awesome. This is going to change my games forever! Thank you!!!!!!

Response to AS: Save and Load 2008-04-16 23:42:22


|||||HEADS UP|||||

You cannot use non alphabetic characters (comas and stuff of that sort) or SPACES in your file name or this will not work. Just thought I would add that.

Response to AS: Save and Load 2008-05-11 01:35:49


hey thanks man! that really helpful

Response to AS: Save and Load 2008-07-12 16:25:46


var savefile = SharedObject.getLocal("yourgamename");

why do u need your games name?

Response to AS: Save and Load 2008-07-12 16:30:07


At 7/12/08 04:25 PM, piggy123 wrote: why do u need your games name?

Dont bump such an old topic for no reason you fucking idiot.


BBS Signature

Response to AS: Save and Load 2008-07-21 10:51:22


Great! Now i need to find out how to use this on a psp..

Response to AS: Save and Load 2008-08-01 15:09:51


At 3/16/05 04:41 PM, szmuk wrote: Thank you...
*bookmarks*

Moi aussi!


if (jackTron (isKing)) {you = areCool} else {gotoAndBurn (hell) }

Response to AS: Save and Load 2008-08-11 21:41:21


I am new to flash. I have Flash CS3 professional, and I see no way of creating a "shared object". Does that mean I am not going to be able to, with my current software, or that I am not looking hard enough? This thread would come in handy if I can create the object.

Response to AS: Save and Load 2008-08-13 06:36:05


okay, and now somebody please tell me where to find the .sol file. NO! I KNOW WHERE IT CAN BE FOUND ON THE PC but i want to know where to find it on a mac. i can't find my .sol (or whatever it's called on mac) and this is a little problem, thanks for every (useful) answer ;D


¯\_(ツ)_/¯

Response to AS: Save and Load 2008-08-13 08:59:21


alright, sorry for the doublepost but i found it:

Library/Preferences/Macromedia/Flash Player/#SharedObjects/2BR3WPJK/localhost /Users/"theUserInWhichTheFileIs"/"dataPa th" (in my case: Documents/Flash/Games/gotchi.swf)


¯\_(ツ)_/¯

Response to AS: Save and Load 2008-08-23 23:55:35


I'm using AS 2 and I need help.

I'm trying to save a variable called _root.highscore. The problem is, that clicking the load button only loads the number zero, although the problem could still be in the save.

Here is my code:

Load Button:

on (press) { var savefile = SharedObject.getLocal("Save and Load"); if (savefile.data.score == undefined) { _root.score = 0; } else { _root.score = savefile.data.score; } }

Save Button

on (release) { savefile.data.score = _root.score; savefile.flush(); }

Remember, I am using AS 2.


Ye

Response to AS: Save and Load 2008-08-23 23:56:36


Oops! I meant that the button was called _root.score


Ye

Response to AS: Save and Load 2009-02-16 04:36:34


to Denvish:
i tried this and it works but the problem is that when i close the movie i lose the save info... how can i do? is there some way to do that?
thanks in advance

Response to AS: Save and Load 2009-08-02 20:32:17


Before I use this, I have a question. If I put a variable on the first frame, will I be able to change it from anywhere in my game? eg, if I'm on frame 50, can I still do whatever+=3;?


BBS Signature

Response to AS: Save and Load 2009-08-04 18:57:02


Just tried testing this. Doesn't seem to work for me

Response to AS: Save and Load 2009-08-18 04:39:06


Is there a way to Save and load the frame of an mc- so it remembers the current frame? and goes back to it after pressing another button?

Response to AS: Save and Load 2009-08-27 00:03:24


your my best friend :D

Response to AS: Save and Load 2009-11-24 14:21:25


Wow, thanks! This is much simpler than I thought it'd be.

But it's not as simple when I have over 90 variables to store D: But still handy.


Excuse me if my 'level' decieves you and puts me off as a noob. For clerifacation, I just dont browse Newgrounds enough to boost it, but I have 5 years of Flash experience.

Response to AS: Save and Load 2009-11-24 14:44:48


At 2/25/05 10:17 AM, Denvish wrote: var savefile = SharedObject.getLocal("yourgamename");
//Grab the level and score held in the file, and assign them to variables

("yourgamename");

should that be the name of the Flash file?


Excuse me if my 'level' decieves you and puts me off as a noob. For clerifacation, I just dont browse Newgrounds enough to boost it, but I have 5 years of Flash experience.

Response to AS: Save and Load 2009-12-28 17:16:33


At 11/24/09 02:44 PM, Pie-4Ever wrote:
At 2/25/05 10:17 AM, Denvish wrote: var savefile = SharedObject.getLocal("yourgamename");
//Grab the level and score held in the file, and assign them to variables
("yourgamename");

should that be the name of the Flash file?

("yourgamename"); is not the name of the flash file.. it practicaly doesn't matter what you write there, if it follows some simple rules - don't use strange signs,spaces etc.
so there could be i.e. ("Blaa"); or ("thereisnomeaning");
This is just the name of the .sol file that is localy stored on the users computer.