Is it possible to pass the contents of an array to javascript code which then creates a text file on the local machine ?
I’m assuming starting from Actionscript right?
Yeah…basically data held in an array in Flash would be passed to javascript array which is then saved in a .txt file on the users local PC.
I got a feeling Javascript can create a .txt file which is great but can Flash pass data to Javascript code ?
Yes, Flash can send data to PHP, but i’m not sure about passing arrays…
How about using:
getURL(“JavaScript:functionname();”);
No, it cannot pass arrays as they are. However, you can convert them into delimited strings using the Array.join method.
[AS]
var myArray = [“Kirupa”, “njs12345”, “thoriphes”];
trace(myArray.join("|")); //outputs ‘Kirupa|njs12345|thoriphes’
[/AS]
Then in php, you can do something like this:
if(isset($_POST['myArray'])){
$myArrayAsString = $_POST['myArray'];
}else{
print("Error occured.");
exit();
}
$myArray = explode("|", $myArrayAsString);
print $myArray[0];
(I realise you want javascript and not PHP, but I don’t know javascript and I happen to be working with something that uses this in PHP at the moment, so it just seemed more convenient.)
That is good for PHP…I want to have flash pass data (held in an array) to a .txt file on a stand alone PC no web server, would PHP run standalone without a web server ?
I don’t want to use shared objects just plain and simple save data to text file, then at some point read from text file…it cannot be too difficult can it ?
Why don’t you want to use shared objects? Shared objects are meant to do what you want them to. They can hold arrays without doing anything, and are extremely easy to make and understand.
I know what you are saying but SO are not as easily distributed…you would not expect a text editor app to write text to a shared object file you would want a .txt
Get where I am coming from…may be it’s not Javascript may be it is another language that can write a text file to the local machine…just not sure which one
What purpose is this for?
Save/ Load Dialogue box:
1. Create a save file dialogue box with the following:
Location: Combobox (Local, Webserver)
-
If location = Local then:
a. Directory: Input text (eg c:\chosendirectory or d:\chosendirectory)
b. Filename: Input text (appends a unique extension .abc)
The data to be saved will then be passed to a language (could be javascript etc) which will create a .abc locally.
-
If location = Webserver then:
a. Domain name: Input text
b. Filename: Input text (appends a unique extension eg .abc)
The data could be passed to PHP to create a text file with .abc extension or better XML.
**2. Create a load file dialogue box with the following: **
Location: Combobox (Local, Webserver)
-
If location = Local then:
a. Directory: Input text (eg c:\chosendirectory or d:\chosendirectory)
b. Filename: Combobox (List of .abc files in directory)
Data is loaded from the .abc
locally.
-
If location = Webserver then:
a. Domain name: Input text
b. Filename: Combobox (List of .abc/ XML files on webserver)
Data is loaded from webserver using PHP from .abc or XML (Better).
Has anyone done a load/save dialogue box before ???