Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: Flash -- text files

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

    Default

    or act as its own webserver
    So... a standalone .exe could be it's own?

    That would be crazy to code, though, right?


    Remember, this would need to be easy to use, as it's going to be distributed with the flash file to use, not just be used by someone who could install or format things for it.



    Other ideas? Something I'm not thinking of searching for in google?
    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. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    So... a standalone .exe could be it's own?
    That would be crazy to code, though, right?
    Not really... a basic webserver such as you're talking about wouldn't be too difficult to implement. It would be a completely ridiculous proposition, though -- firewalls would have all sorts of problems, for a start, and I'm sure there must be a way of doing this properly. It would be like building a castle so you could hang your hat on a hook in one of the rooms.
    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. #13
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sure. Not saying it isn't a big thing for something fairly little.

    I'll look more at flash.

    Hope I find something better for this. Just haven't had much luck so far.
    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. #14
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Not sure I FULLY understand what exactly you are trying to accomplish here... BUT...

    You sound like a very intelligent person, so reading between the lines and manipulating what you need to get the results you are after shouldn't be too tough.

    If you are looking for the ability to save things locally on someone's PC, using flash... try shared objects.

    HERE is a short tutorial with coding.

    And This One has more detail and uses cookies, which are .txt files yes?

    This One uses SQL and php to store data such as player position, inventory, etc. WIth good instructions, shouldn't be too hard to tweak.

    Finally this one is your basic highscore list, which I have used many time (after getting to work properly with php4+) Again, using INSERT and POST/GET to store info to a .sco file (can be renamed to .txt if needed)

    if you look at the last one, download the zip file and replace the scores.php with this:

    Code:
    <?php
    error_reporting(E_ALL);
    function getPlayerScore() {
        // get the winscore variable from the query string - make sure it's an integer
        $score  = (isset($_GET['winscore'])) ? (int) $_GET['winscore'] : 0;
        // get the winname variable removing leading and trailing whitespace and the | character
        $name   = (isset($_GET['winname'])) ? trim(str_replace('|', ' ', $_GET['winname'])) : '';
    
        // high score records are stored as score|name
        return $score . '|' . $name;
    }
    
    function getAction() {
        // an array containing the possible actions
        $actions = array('VIEW', 'INSERT', 'CLEAR');
    
        $action = (isset($_GET['action'])) ? trim(strtoupper($_GET['action'])) : 'VIEW';
        // make sure the action is valid
        if (!in_array($action, $actions)) {
            $action = 'VIEW';
        }
        return $action;
    }
    
    function createFile($filename) {
        // if a the file doesn't exist try to create it
        if (!file_exists($filename)) {
            $fp = fopen($filename, 'w');
            if (!$fp) {
                // the file couldn't be created
                return false;
            }
            fclose($fp);
        }
        // if we got here the file is ok
        return true;
    }
    
    function writeFlash($name, $value, $exit = false) {
        // write out a variable name and value to be read by flash
        echo '&' . $name . '=' . urlencode($value) . '&';
        // if $exit has been set stop the script right here
        if ($exit) {
            exit();
        }
    }
    
    function writeFile($filename, $str) {
        // write a string to a file
        $fp = fopen($filename, 'w');
        fwrite($fp, $str);
        fclose($fp);
    }
    
    function process() {
        // define the location of the highscores file
        $scoreFile = 'scores/highscores.sco';
        // and define the number of results 
        $scoreSize = 10;
        // get the action so we know what to do!
        $action = getAction();
    
        // try to create the highscores file if it doesn't exist already
        if (!createFile($scoreFile)) {
            // if the file didn't exist and can't be created return an error message
            writeFlash('status', 'There was an error accessing the highscores list', true);
        }
    
        if ($action == 'CLEAR') {
            // clear the scores file
            writeFile($scoreFile, '');
            // and send a message back to flash
            writeFlash('status', 'The list has been cleared', true);
        }
    
        // read the scores in the file into an array
        $fileScores = array_map('trim', file($scoreFile));
        if ($action == 'INSERT') {
            // if we've got a score to add to the end of it
            $fileScores[] = getPlayerScore();
        }
    
        // an create a couple of empty arrays that we'll use for sorting our data
        $scores = array();
        $names = array();
        foreach ($fileScores as $scoreData) {
            // put the scores and names into the 2 arrays
            list($scores[], $names[]) = explode('|', $scoreData);
        }
        // sort it! get $fileScores sorted so the scores are in descending order
        array_multisort($scores, SORT_DESC, $names, SORT_ASC, $fileScores);
        // if we have too many scores trim off the lowest ones
        array_splice($fileScores, $scoreSize, count($fileScores) - $scoreSize);
    
        // write the content of the fileScores array into the file (with each score|name separated by a newline)
        writeFile($scoreFile, implode("\n", $fileScores));
        // loop through the scores
        foreach ($fileScores as $key => $scoreData) {
            $tmp = explode('|', $scoreData);
            // and write out a list of variables score0, name0, score1, name1 etc...
            writeFlash('score' . $key, $tmp[0]);
            writeFlash('name' . $key, $tmp[1]);
        }
        writeFlash('status', 'things are fine');
    }
    
    process();
    
    
    ?>
    Of course, all of these are meant for games, but again, easily tweaked for your needs... that is, IF I understood what you wanted to do.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

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

    Default

    Again, using INSERT and POST/GET to store info to a .sco file
    (a hundred thousand Linux geeks team up to stop it ever becoming a recognised file format)

    This INSERT would be what's being looked for, at a guess.
    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!

  6. #16
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Does file format REALLY matter when you are writing/reading an interal file? It is just a name and declaration, yes?

    I mean I could tell my Flash to get data from file.dogpoo, and as long as file.dogpoo exsits where I told it to look for it, it should read the info either way...

    This, of course on a GRAND generic scale...
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

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

    Default

    I mean I could tell my Flash to get data from file.dogpoo, and as long as file.dogpoo exsits where I told it to look for it, it should read the info either way...
    As I've said above: the extension doesn't matter, it's only an indicator of the format of the file and doesn't necessarily have any bearing on the contents.

    I was talking about the massive SCO debate... don't worry, there's sure to be someone who'll appreciate it.
    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!

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

    Default

    I didn't read through everything above, but I will when I get a chance. Thanks.

    However, you're giving me a php code, which is exactly what I can't use... this needs to be local.
    Is that just an example of what could be a non-php script?


    EDIT: ok... just looked a little more. cookies won't work because this needs to be distributed to people, and asking them to check their cookies for the file is a bit much for not-so-advanced computer users.
    Also, cookies are cleared, so you'd need to manually find the cookie and change it to avoid it getting deleted the next time you clear your cookies from your browser.

    Thanks again for the links, though... maybe one will prove useful in finding a local way to do it.
    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

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

    Default

    The top link is pure ActionScript. It also appears to have obtained its information from an internetsite site, so it must be good.
    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!

  10. #20
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by djr33
    EDIT: ok... just looked a little more. cookies won't work because this needs to be distributed to people, and asking them to check their cookies for the file is a bit much for not-so-advanced computer users.
    Also, cookies are cleared, so you'd need to manually find the cookie and change it to avoid it getting deleted the next time you clear your cookies from your browser.

    Thanks again for the links, though... maybe one will prove useful in finding a local way to do it.

    Well, cookies are just txt files, yes? and you can add actionscript to tell it where to create/store the info, be it in the cookies folder, or in a savefile folder created on the users desktop...

    Twey is right though, I think the first is your best bet, using teh shared objects is all internal, so you wouldn't even need the extra txt file
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

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
  •