Forum Topic: AS: Save and Load

(16,015 views • 121 replies)

This topic is 5 pages long. [ 1 | 2 | 3 | 4 | 5 ]

<< < > >>
None

liaaaam

Reply To Post Reply & Quote

Posted at: 4/9/07 10:56 PM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

At 4/9/07 10:29 PM, Thomas wrote: Good question

Good question, wrong thread [sorta]. That is very possible, and I only currently see the technique being used for uber-hackable high score boards in various score keeping games; rather than the awesome idea of letting a user save stuff permanently. It's an idea I've always loved, seeing as the saving method flash has is kinda jerky - the player should be able to load up his save from any PC he uses and this would allow that using a username+password scheme. I've never set up a working example because A) No need, and B) I don't really have a server.

Look into php/flash integration, sending variables to and from a server using Flash and yes MySQL would be advisable as it would be more secure and easier to manage in a long term situation.

Any questions? ;P


None

Thomas

Reply To Post Reply & Quote

Posted at: 4/9/07 10:59 PM

Thomas LIGHT LEVEL 13

Sign-Up: 02/14/05

Posts: 2,833

At 4/9/07 10:56 PM, liaaaam wrote:
At 4/9/07 10:29 PM, Thomas wrote: Good question
Good answer

I'm probably gonna try and find out more about it later,but I have to go for now.Thanks for answer.


None

Thomas

Reply To Post Reply & Quote

Posted at: 4/23/07 06:12 PM

Thomas LIGHT LEVEL 13

Sign-Up: 02/14/05

Posts: 2,833

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...


None

Hornby

Reply To Post Reply & Quote

Posted at: 6/4/07 01:57 AM

Hornby DARK LEVEL 21

Sign-Up: 06/22/06

Posts: 4,397

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


None

edit-undo

Reply To Post Reply & Quote

Posted at: 6/22/07 10:49 AM

edit-undo LIGHT LEVEL 18

Sign-Up: 01/17/06

Posts: 1,776

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

lolsigtrend
i just wanna fit in :'(

BBS Signature

None

archeris

Reply To Post Reply & Quote

Posted at: 6/24/07 03:36 PM

archeris EVIL LEVEL 19

Sign-Up: 04/01/06

Posts: 65

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


None

Nqkoi1

Reply To Post Reply & Quote

Posted at: 6/30/07 02:20 PM

Nqkoi1 DARK LEVEL 13

Sign-Up: 04/29/07

Posts: 565

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

Misunderstood

nbstudios

Reply To Post Reply & Quote

Posted at: 7/21/07 10:38 AM

nbstudios NEUTRAL LEVEL 05

Sign-Up: 08/20/04

Posts: 8

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?


None

Deathcon7

Reply To Post Reply & Quote

Posted at: 7/21/07 10:44 AM

Deathcon7 NEUTRAL LEVEL 21

Sign-Up: 10/01/03

Posts: 5,840

Name of the cookies have to match.


None

nbstudios

Reply To Post Reply & Quote

Posted at: 7/21/07 11:28 AM

nbstudios NEUTRAL LEVEL 05

Sign-Up: 08/20/04

Posts: 8

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;
}
}


None

SnailsAnimation

Reply To Post Reply & Quote

Posted at: 10/30/07 10:05 PM

SnailsAnimation DARK LEVEL 31

Sign-Up: 03/29/06

Posts: 21

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.


Misunderstood

Kio-Xion

Reply To Post Reply & Quote

Posted at: 12/12/07 07:49 PM

Kio-Xion LIGHT LEVEL 07

Sign-Up: 08/20/07

Posts: 89

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.


Elated

liamizdabest

Reply To Post Reply & Quote

Posted at: 1/2/08 06:13 PM

liamizdabest EVIL LEVEL 02

Sign-Up: 12/09/07

Posts: 178

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


Mad as Hell

Wrobel

Reply To Post Reply & Quote

Posted at: 1/28/08 01:05 AM

Wrobel EVIL LEVEL 03

Sign-Up: 08/26/05

Posts: 6

can you please explain this more specifcly


None

Matt-Porter

Reply To Post Reply & Quote

Posted at: 4/16/08 11:42 PM

Matt-Porter FAB LEVEL 28

Sign-Up: 08/09/04

Posts: 1,064

|||||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.


Happy

emboness

Reply To Post Reply & Quote

Posted at: 5/11/08 01:35 AM

emboness NEUTRAL LEVEL 02

Sign-Up: 04/11/08

Posts: 1

hey thanks man! that really helpful


None

piggy123

Reply To Post Reply & Quote

Posted at: 7/12/08 04:25 PM

piggy123 NEUTRAL LEVEL 14

Sign-Up: 06/13/08

Posts: 925

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

why do u need your games name?


None

CaiWengi

Reply To Post Reply & Quote

Posted at: 7/12/08 04:30 PM

CaiWengi EVIL LEVEL 07

Sign-Up: 09/17/04

Posts: 1,518

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.

Sig by ApothicFlash <3

BBS Signature

Happy

Gregoyk

Reply To Post Reply & Quote

Posted at: 7/21/08 10:51 AM

Gregoyk NEUTRAL LEVEL 03

Sign-Up: 01/12/08

Posts: 13

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


None

JackTron7000

Reply To Post Reply & Quote

Posted at: 8/1/08 03:09 PM

JackTron7000 NEUTRAL LEVEL 03

Sign-Up: 01/11/08

Posts: 143

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

Moi aussi!

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


None

Cyclone103

Reply To Post Reply & Quote

Posted at: 8/11/08 09:41 PM

Cyclone103 LIGHT LEVEL 05

Sign-Up: 08/07/08

Posts: 65

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.


Shouting

OctoFlash

Reply To Post Reply & Quote

Posted at: 8/13/08 06:36 AM

OctoFlash DARK LEVEL 17

Sign-Up: 12/02/06

Posts: 839

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

BLAM DAMN SPAM. That rhymes! So what do we learn?
the right answer for the most bbs-posts: THE FREAKIN' COLLAB RULES!!!

BBS Signature

Elated

OctoFlash

Reply To Post Reply & Quote

Posted at: 8/13/08 08:59 AM

OctoFlash DARK LEVEL 17

Sign-Up: 12/02/06

Posts: 839

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)

BLAM DAMN SPAM. That rhymes! So what do we learn?
the right answer for the most bbs-posts: THE FREAKIN' COLLAB RULES!!!

BBS Signature

None

UberCream

Reply To Post Reply & Quote

Posted at: 8/23/08 11:55 PM

UberCream NEUTRAL LEVEL 18

Sign-Up: 11/19/05

Posts: 3,066

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.


None

UberCream

Reply To Post Reply & Quote

Posted at: 8/23/08 11:56 PM

UberCream NEUTRAL LEVEL 18

Sign-Up: 11/19/05

Posts: 3,066

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


None

soulslayer88

Reply To Post Reply & Quote

Posted at: 2/16/09 04:36 AM

soulslayer88 NEUTRAL LEVEL 02

Sign-Up: 02/16/09

Posts: 9

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


None

TheCupcakeArmy

Reply To Post Reply & Quote

Posted at: 8/2/09 08:32 PM

TheCupcakeArmy FAB LEVEL 08

Sign-Up: 09/29/08

Posts: 258

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;?

Please scout me for the art portal!


None

UnrealCanine

Reply To Post Reply & Quote

Posted at: 8/4/09 06:57 PM

UnrealCanine DARK LEVEL 16

Sign-Up: 02/06/08

Posts: 119

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


Questioning

nick9001

Reply To Post Reply & Quote

Posted at: 8/18/09 04:39 AM

nick9001 LIGHT LEVEL 07

Sign-Up: 05/05/08

Posts: 75

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?


Elated

doondeka

Reply To Post Reply & Quote

Posted at: 8/27/09 12:03 AM

doondeka EVIL LEVEL 17

Sign-Up: 03/25/07

Posts: 159

your my best friend :D

you never regret what you do until it gets in the face of death but its to late to opolgize your going to hell and il be your host...

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 01:23 AM

<< Back

This topic is 5 pages long. [ 1 | 2 | 3 | 4 | 5 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!