Be a Supporter!

[as2]ng Api Savefile Not Working

  • 598 Views
  • 12 Replies
New Topic Respond to this Topic
silverneo188
silverneo188
  • Member since: Jan. 29, 2006
  • Offline.
Forum Stats
Member
Level 11
Programmer
[as2]ng Api Savefile Not Working Jun. 25th, 2012 @ 02:37 PM Reply

I am using this code

import com.newgrounds.*;
var file : SaveFile;
file.name = "Test 1";
file.description = "A Mage File";
file.data = {Character Name: "Test Name", Class: "Mage", Level: 10};
file.addEventListener(APIEvent.FILE_SAVED, onFileSaved);
file.save();

function onFileSaved(event : APIEvent) : void
{
  if(event.success) { trace("File saved!"); }
}

I know i'm not supposed to use static variables but I am just trying to get it to work first.
It's not sending anything back.

My Group Name is FightMeCharacter
My Keys are Character Name, Class, andLevel

Any idea why it isn't working?

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 25th, 2012 @ 02:41 PM Reply

Are you using API.connect() to connect to NG?


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
silverneo188
silverneo188
  • Member since: Jan. 29, 2006
  • Offline.
Forum Stats
Member
Level 11
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 25th, 2012 @ 02:43 PM Reply

Yes, I get this when I load up my game

[Newgrounds API] :: ====== Newgrounds API v3.1.2 AS2 ======
[Newgrounds API] :: Connecting to the Newgrounds API Gateway...
[Newgrounds API] :: ----- Tralaira RPG -----
[Newgrounds API] :: Medal: Started anew		(locked, 5pts, Easy)
[Newgrounds API] :: 1 medal initialized.
[Newgrounds API] :: 0 scoreboards initialized.
[Newgrounds API] :: SaveGroup: FightMeCharacter  Keys: Character Name,Class,Level  Ratings: 
[Newgrounds API] :: 1 save group initialized.
[Newgrounds API] :: Connection complete!
MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 25th, 2012 @ 02:58 PM Reply

Maybe remove the if(event.success) ?
Does it trace then?


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
silverneo188
silverneo188
  • Member since: Jan. 29, 2006
  • Offline.
Forum Stats
Member
Level 11
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 25th, 2012 @ 04:27 PM Reply

At 6/25/12 02:58 PM, MintPaw wrote: Maybe remove the if(event.success) ?
Does it trace then?

no still does not trace... hmmm I have a feeling it has something to do with this:

var file : SaveFile = API.createSaveFile("FightMeCharacter");

I'm using AS2 can you use the colon to declare an object type like that in AS2?

silverneo188
silverneo188
  • Member since: Jan. 29, 2006
  • Offline.
Forum Stats
Member
Level 11
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 25th, 2012 @ 04:32 PM Reply

I think I found my error.
Current code

import com.newgrounds.*;
var file : SaveFile = API.createSaveFile("FightMeCharacter");
file.name = "Test 1";
file.description = "A Mage File";
file.data = {Character Name: "Test Name", Class: "Mage", Level: 10};
file.addEventListener(APIEvent.FILE_SAVED, onFileSaved);
file.createIcon(icon);
file.save();

function onFileSaved(APIEvent){
  trace("File saved!");
}

The compile error flash is throwing me (Note: It is line 5 in this code)

Scene=Scene 1, layer=Main Layer, frame=73, Line 5	':' expected

What does it mean? I tried putting "Character Name" in quotes but that throws me this error
Code

import com.newgrounds.*;
var file : SaveFile = API.createSaveFile("FightMeCharacter");
file.name = "Test 1";
file.description = "A Mage File";
file.data = {"Character Name": "Test Name", "Class": "Mage", "Level": 10};
file.addEventListener(APIEvent.FILE_SAVED, onFileSaved);
file.createIcon(icon);
file.save();

function onFileSaved(APIEvent){
  trace("File saved!");
}

Error
Scene=Scene 1, layer=Main Layer, frame=73, Line 5 Identifier expected

silverneo188
silverneo188
  • Member since: Jan. 29, 2006
  • Offline.
Forum Stats
Member
Level 11
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 25th, 2012 @ 04:37 PM Reply

OK I did this code

import com.newgrounds.*;
var file : SaveFile = API.createSaveFile("FightMeCharacter");
file.name = "Test 1";
file.description = "A Mage File";
file.data = {String: "Test Name", String: "Mage", Integer: 10};
file.addEventListener(APIEvent.FILE_SAVED, onFileSaved);
file.createIcon(icon);
file.save();

function onFileSaved(APIEvent){
  trace("File saved!");
}

BUT None of the data I passed in the file.data worked, they all returned null. What am I not passing right? And also how do I upload an Icon with the save?

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 25th, 2012 @ 06:22 PM Reply

Umm, I'm not sure how custom classes work in AS2, and I don't know how I didn't read that in the title. There's no documentation of the AS2 NG API. I feel like I say this to much, but AS2 is ten years old, I mean like, this languages is almost from the 90's there's very good reasons no one uses this language anymore.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
silverneo188
silverneo188
  • Member since: Jan. 29, 2006
  • Offline.
Forum Stats
Member
Level 11
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 26th, 2012 @ 06:08 PM Reply

Lame, AS3 is a bitch tho haha

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 26th, 2012 @ 06:59 PM Reply

At 6/26/12 06:08 PM, silverneo188 wrote: Lame, AS3 is a bitch tho haha

You mean you can't copy AS3 tutorials, instead you have to actually learn something. Then yes, it's a bitch.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
silverneo188
silverneo188
  • Member since: Jan. 29, 2006
  • Offline.
Forum Stats
Member
Level 11
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 27th, 2012 @ 07:54 AM Reply

Lol sorry if I came off as arrogant there -_- I've tried numerous times to learn it and have gotten really confused each time I try to learn it. Would you consider restarting my current project in AS3? I'm not too far but idk if I could convert my current code into AS3, there is quite a bit of it (Even tho the project itself isn't very far)

milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Online!
Forum Stats
Member
Level 26
Programmer
Response to [as2]ng Api Savefile Not Working Jun. 27th, 2012 @ 08:33 AM Reply

At 6/27/12 07:54 AM, silverneo188 wrote: Would you consider restarting my current project in AS3?

If you stopped asking rhetoric questions you could be done with your project in As3 already.
We'd be glad to help you achieving this goal if any questions occur.

This should get you started with As3:
http://active.tutsplus.com/sessions/as3-101/

More stuff here:
http://milchreis.newgrounds.com/news/post/576285

PSvils
PSvils
  • Member since: Feb. 3, 2010
  • Offline.
Forum Stats
Member
Level 01
Game Developer
Response to [as2]ng Api Savefile Not Working Jun. 27th, 2012 @ 11:17 AM Reply

At 6/25/12 04:32 PM, silverneo188 wrote: file.data = {Character Name: "Test Name", Class: "Mage", Level: 10};

Broski...

Check out Flash's variable naming scheme/rules maybe...