|
-
[RESOLVED] [AS2] Argh, just ONE VARIABLE SAVE!?
Seriously, saving is out to kill me.
Sometimes it works, and then when I do the exact same thing another time it decides not to and I'm extremely frustrated. Let me break down this extremely, extremely simple setup:
Basically for a simple game I'm making, I just want to store three (I know I said 'one variable', but it won't even work with one...) things about the top highscore player. Name, Score, and Message. SIMPLE. So, I start by loading it:
Load the Three Existing Variables
PHP Code:
myData = new LoadVars(); myData.onLoad = function() { champName.text = myData.Name; champScore.text = myData.Score; champMsg.text = myData.Msg; topScore = myData.Score; }; myData.load("save.txt?"+Math.ceil(random(9999)));
Great, it works fine when I test it and everything. You play the game, you eventually lose, and then it does a highscore check. If you get the highscore, you are asked for you name and a simple message.
When you click submit, the function saveScore() is called and looks like so:
Send Everything to PHP
PHP Code:
saveScore = function () { myData.Name = topName; myData.Score = topScore; myData.Msg = topMsg; myData.sendAndLoad("save.php",myData,"POST"); _root.gotoAndStop(1); };
Any trace done will return the proper value, including trace(myData) will return all three updated variables (Name, Score, Msg). Then it sends it to the PHP for saving.
The PHP is like so:
Write to Text File
PHP Code:
<?php $saveName = $_POST['Name']; $saveScore = $_POST['Score']; $saveMsg = $_POST['Msg'];
$toSave = "Name=".$saveName."&Score=".$saveScore."&Msg=".$saveMsg
$myfile = fopen("save.txt","w"); fwrite($myfile,$toSave); fclose($myfile); ?>
Grab each, store it all in one variable and write it to the text file.
SIMPLE!?
I don't know, it just won't write to the text file! Someone, please save me from my misery so I can continue on with my project.
Last edited by Osteel; 11-20-2009 at 05:10 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|