A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [AS2] Saving: code doesn't work.

  1. #1
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167

    [AS2] Saving: code doesn't work.

    Hey everyone,

    Okay, I know this is an old topic by now. I've searched numerous places how to save to a simple text file, and at one point in my life I was able to do it. However, the code doesn't seem to work anymore ...


    Flash Code:

    Code:
    myData = new LoadVars();
    
    submit.onRelease = function() {
    	myData.Name = textbox.text;
    	myData.sendAndLoad("save.php",myData,"POST");
    
    }

    PHP Code:

    PHP Code:
    <?php
    $name 
    $_POST['Name'];
    $toSave ="Name=$name;"
     
    $fp fopen("saveLocal.txt""w");
    fclose($fp);
    ?>

    Very simple it would seem, but it doesn't work. Thoughts?

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try -
    PHP Code:
    $myfile fopen("saveLocal.txt","w");
    $fp fwrite($myfile,$toSave);
    fclose($myfile); 

  3. #3
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    I've tried it and it doesn't work either. The thing is, it all makes perfect sense ... yet it just doesn't want to work!

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try -
    PHP Code:
    $toSave ="Name=".$name

  5. #5
    Senior Member
    Join Date
    Apr 2009
    Posts
    117
    i use get and post function in flash then use arrays in php like [_$post] kinda like that but just mess around with what you have got nd it will eventualy work

  6. #6
    Senior Member
    Join Date
    Apr 2009
    Posts
    117
    ohh i see its the php that aint working, you should use mysql and it might be your chmmod or whatever it is called on the saveLocal.txt file

  7. #7
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Still nothing, although what you wrote would make sense. Also, Milna, what do you mean by my 'chmmod' (or whatever it is, haha :P)

    I don't remember ever having to alter a text file. But then again, I did it two years ago so I don't remember anything.

  8. #8
    Senior Member
    Join Date
    Aug 2007
    Posts
    228
    Here , this was on a tutorial somewhere, it sends the player a cookie, I dont know, maybe you dont want to do it that way?

    But here is the code, I dont remember where i got this tutorial.


    You do this part once, let it fire at the beginning of game loadup

    var thevar = 0;


    Code:
    function dothing (){
        Object.prototype.setCookie = function(c, n, v) {
        var so = SharedObject.getLocal(c);
        so.data[n] = v;
        so.flush();
        };
        Object.prototype.getCookie = function(c, n) {
        var so = SharedObject.getLocal(c);
        return so.data[n];
        };
    }



    You put this on your save button


    Code:
    this.setCookie("mv","myvar", thevar)

    and this on your load button

    Code:
     thevar = this.getCookie("mv","myvar")
    thevar obviously being the variable you want to save, but you can use arrays too of course.

    I hope that helped, but im guessing not because you were using a different method

  9. #9
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Yeah a cookie would work, but not for what I had in mind. I just wanted to simply save some information so that if anyone goes to a given link, the information can be retrieved.

  10. #10
    Senior Member
    Join Date
    Apr 2009
    Posts
    117
    chmmod is the 3digits that give the permissions to a file for example "755" etc. on some servers it can also be called set permissions or just permissions on a file,for php file to access and edit another file onthe server it needs the file its editings permissions changing, heres 2 links to explain it in more detail if you dont understand
    http://codex.wordpress.org/Changing_File_Permissions
    http://www.stadtaus.com/en/tutorials...ermissions.php

  11. #11
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    That's interesting. I checked the PHP file and it was set to 'write' under all three types of users. It's just ... I found it really simple back in the day when I was doing this. I wonder if things had changed?

    But I was using CS3, so I'm not sure why it's not working anymore. :'(

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center