Text in flash

  • stev_ro
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: ro

Post 3+ Months Ago

How can i save a text from flash into an external txt file.
(without using databases or servers, just saving the text in a txt file on the local hard drive).
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

from flash you can't save the text in a text file without using a server side script. You can use Zinc or you can use the sharedObject class from flash (read the help for it) to save on the local machine, but not in any text file, just in a fixed location, something like a browser cookie.
  • stev_ro
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: ro

Post 3+ Months Ago

I found this command for projectors :
MMsave(var_name,"textfile_name.txt");
(where var_name is the name of the input text field and textfile_name is the name that i want my txt file to have).

But this can only save in C:\program files\flash8\configuration. Isn't there any command that can use any address i want?
Because i have a standalone app, i only need to save on the local hard drive not on a server.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

seems like MMsave uses the shared object class to save.
There ain't other way to save locally in a text file than those i presented above, due to flash security. Either server side script, or a 3rd party application like Zinc.
  • stev_ro
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: ro

Post 3+ Months Ago

Thx!:)
  • stev_ro
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: ro

Post 3+ Months Ago

I managed to save the text from flash to .txt files and furthermore I can load it back.:D
This is the as:
Code: [ Select ]
var myVars:LoadVars = new LoadVars();
var myData:LoadVars = new LoadVars();
myVars.onLoad = function() {
    
    if (myVars.verify == "success") {
        status_txt.text = "data Saved";
    } else {
        status_txt.text = "Failed Save";
    }
};
save_btn.onRelease = function() {
        myVars.problema = specificatie_txt.text;
        myVars.raspuns = raspuns_txt.text;
        myVars.punctaj = punctaj_txt.text;
        myVars.sendAndLoad("WriteToFile.php",myVars,"POST");
};
load_btn.onRelease = function() {
    myData.load("specificatie_cap1.txt");
    myData.onLoad = function(succes) {
        if (succes) {
            specificatie_txt.text = this.problema_txt;
            status1_txt.text = "Incare reusita";
        } else {
            status1_txt.text = "Eroare la incarcare";
        }
    };
};
  1. var myVars:LoadVars = new LoadVars();
  2. var myData:LoadVars = new LoadVars();
  3. myVars.onLoad = function() {
  4.     
  5.     if (myVars.verify == "success") {
  6.         status_txt.text = "data Saved";
  7.     } else {
  8.         status_txt.text = "Failed Save";
  9.     }
  10. };
  11. save_btn.onRelease = function() {
  12.         myVars.problema = specificatie_txt.text;
  13.         myVars.raspuns = raspuns_txt.text;
  14.         myVars.punctaj = punctaj_txt.text;
  15.         myVars.sendAndLoad("WriteToFile.php",myVars,"POST");
  16. };
  17. load_btn.onRelease = function() {
  18.     myData.load("specificatie_cap1.txt");
  19.     myData.onLoad = function(succes) {
  20.         if (succes) {
  21.             specificatie_txt.text = this.problema_txt;
  22.             status1_txt.text = "Incare reusita";
  23.         } else {
  24.             status1_txt.text = "Eroare la incarcare";
  25.         }
  26.     };
  27. };

For saving the text I'm using php...so here is the code:
Code: [ Select ]
<?php

$problema = $_POST['problema']; //gets the variable from flash
$adaugare = "input_txt=" . $problema;//this is needed in order to be able to load the text

$open = fopen("specificatie_cap1.txt", 'w'); //create the .txt file
$write = fwrite($open, $adaugare); //writes the data

//sends a response back to flash stating success or failure
if($write) { //since fwrite returns a value of true or false, $write will be either true or false
    echo "&verify=success&"; //prints to screen &verify=success which flash will read and store as myVars.verify
} else { // simple if statement
    echo "&verify=fail&"; //prints to screen &verify=fail which flash will read and store as myVars.verify
}
?>
  1. <?php
  2. $problema = $_POST['problema']; //gets the variable from flash
  3. $adaugare = "input_txt=" . $problema;//this is needed in order to be able to load the text
  4. $open = fopen("specificatie_cap1.txt", 'w'); //create the .txt file
  5. $write = fwrite($open, $adaugare); //writes the data
  6. //sends a response back to flash stating success or failure
  7. if($write) { //since fwrite returns a value of true or false, $write will be either true or false
  8.     echo "&verify=success&"; //prints to screen &verify=success which flash will read and store as myVars.verify
  9. } else { // simple if statement
  10.     echo "&verify=fail&"; //prints to screen &verify=fail which flash will read and store as myVars.verify
  11. }
  12. ?>

You will notice that for loading I'm not using any serverside code , just as. If anyone has any questions just ask.:D

Now I'll try to make it save&load the text to/from a my_sql database. If needed I will post that script also.:D
_____________________
http://forums.updateflashevents.com
http://forums.gridfusion.com if you want more flash&other help

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 4 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.