Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Flash -- text files

  1. #1
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default Flash -- text files

    For a project, I need to be able to save the current values of variables in a text file, then load them again.

    Using the function load() and specifying the text file, it's quite easy to get the values back, using a format similar to the get method of the web (var1=val1&var2=val2&...).

    However, the send() function, which seems to be the inverse of load(), only sends get or post data.

    Load will work with the text files, then, but send will just send post data to a text document which will, if lucky, do nothing or, if unlucky, give you errors or crash or something.

    So.... ironically, it would be easy in this case to do it on the web with php, etc, but the text file needs to be the output for this as it will be local. No webpages should be used.

    also, the other hard part will be not just adding to the .txt, but actually creating a new .txt when you save.

    Any ideas?


    One thing I thought of was if there's a way to code a program in C++ or somethign that would be able to accept POST data, but that seems quite complex.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What format do you want them in? You can code a program to do it, but it would have to run as a web service.

    PHP doesn't have to be run on a server, you know
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Yeah, I know you can install php locally, but it's more work than people would want to do.
    This isn't a personal thing, but something that will be distributed to people, many of whom would probably have no idea how to (or interest in) installing php to their computer.

    .txt format would be great. perhaps coming up with a new extension would be nice, just so they don't think it's a text file. Maybe .fsv (or .fsave), or something. But that shouldn't be hard to change, right?
    But... for formatting of the info itself, just a long string of var=val&var=var.... with no linebreaks/spaces/etc. would be great.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    .txt format would be great. perhaps coming up with a new extension would be nice, just so they don't think it's a text file. Maybe .fsv (or .fsave), or something. But that shouldn't be hard to change, right?
    A format isn't the same as an extension.
    Yeah, I know you can install php locally, but it's more work than people would want to do.
    Well, it sounds to me as if the function you're suggesting you use can only handle sending requests via HTTP.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    A format isn't the same as an extension.
    Right, but sometimes it's easier to save a text file as .txt than it would be to save it as .jpg, for example. Some programs and/or options make custom extensions a bit harder to use. But.. yeah, I'd think it possible if coding a custom app.


    It could send locally.... you could sent it to a file on the harddrive. Maybe with javascript, it would work.
    however, it would be nice to not to rely on JS.

    You mentioned making a program... could it accept POST data?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You mentioned making a program... could it accept POST data?
    Yes. But this would essentially mean building a mini HTTP server, which is a remarkably ugly and inefficient way of doing things.
    It could send locally.... you could sent it to a file on the harddrive. Maybe with javascript, it would work.
    GET requests cannot be sent to local files.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    GET requests.... not even if you have php installed? With a php file? Why is that?
    But.... flash also offers POST. Is it the same with that, though?


    ....a remarkably ugly and inefficient way of doing things.
    Yeah, but what's your better suggestion?
    I'll keep looking before I dive into that.
    Just can't find anything on google.. I've looked a lot.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    not even if you have php installed? With a php file? Why is that?
    But.... flash also offers POST. Is it the same with that, though?
    You'd have to understand the basic workings of HTTP to understand this. To send a request via HTTP, be it GET, POST, HEAD, whatever, the program (or script, in your case) must connect to an HTTP server, to which it sends something like this (to get http://mysite.com/dir/fish.html):
    Code:
    GET /dir/fish.html HTTP/1.1
    Host: mysite.com
    Note the two linebreaks on the end. The server then responds with some information about the resource and the result of the request:
    Code:
    HTTP/1.x 200 OK
    Date: Sun, 18 Jun 2006 10:31:16 GMT
    Server: Apache
    Connection: Close
    Content-Type: text/html;charset=Shift_JIS
    (again, note the two linebreaks on the end), before proceeding to send the requested data. Both examples were simplified for the purpose of demonstration, but perfectly accurate; you can try it in telnet if you're a fast typist. As you can see. HTTP is very different from accessing a local file, so unless there's a webserver running on the local computer, it's not going to happen. Flash may provide some sort of HTTP-styled wrapper for opening local files, but I doubt it; from what you say (that it offers both GET and POST to local files) I think that you're simply wrong.

    I daresay it has a more suitable function for accessing local files. You should go through the docs again.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Yeah, I'll definitely keep looking. I've just found the load function which does work locally, but the send only does webbased (get/post) sending.
    Google doesn't help when "flash text file" is searched for, and there isn't much info it. I don't doubt there is another function, but I haven't found any info on it.


    I know HTTP is different, but thanks for the specific example.
    Bottom line... you can't use a standalone file (like an .exe) to accept POST (etc) data, right? I suspected this, but wanted to be sure.


    I didn't say it offered GET and POST for local files, but just that it offers both and you could supply a relative or local URL if you desired. Not saying that it would neccessarily work.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Bottom line... you can't use a standalone file (like an .exe) to accept POST (etc) data, right?
    You can, but it must use a socket connection somewhere along the line (I.E. either run as a CGI program or act as its own webserver).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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