| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Mar 2001
Posts: 9
|
I've got the hang of reading data from a text file, but is there any way of writing to one? I don't know a thing about php or xml. I'm trying to write a scoreboard for a game i've written.
Cheers. |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Feb 2001
Location: vancouver
Posts: 2,219
|
Hi...
You'll need a server-side scripting solution...PHP, ASP, etc...then you use loadVariables to send info from Flash out to the php script... Here's a basic php script to get you started...this will write all variables in your flash movie into the text file test.txt. The SWF file, test.txt, and the php script file should all be in the same directory for this to work... <?php $data="test.txt"; $fp= fopen($data, "w+"); $fw= fwrite($fp,"$QUERY_STRING"); fclose($fp); echo "status=Done" ?> Hope this helps, K. |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Mar 2001
Posts: 9
|
Thanks for that. How do I link the swf to the php? And I'm assuming having a file anything.php3 with just the code you gave me will work - no extra code is needed.
|
|
|
|
|
|
#4 |
|
Registered User
Join Date: Feb 2001
Location: vancouver
Posts: 2,219
|
Copy the php script into a text editor and save it out as anything.php
Then in the Flash movie you would trigger it with the action: loadVariablesNum ("anything.php", 0 ,"POST"); Note that this is a really basic script, there's no error checking or anything- it just dumps all variables into the text file... Hope this helps, K. |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Mar 2001
Posts: 9
|
I don't want to appear stupid, but I can't help it!
I've got the php code in a file called anything.php and have a swf file with 2 named text fields with values loaded from a txt file. That works. I have a button which has loadVariablesNum ("anything.php", 0 ,"POST"); as the only thing in the 'on' call. I also have a txt file test.txt in the same dir as the others. I've tried looking up php codes but have only found it with mysql. Can you suggest anything?! Cheers |
|
|
|
|
|
#6 |
|
Registered User
Join Date: Feb 2001
Location: vancouver
Posts: 2,219
|
You may need to set the CHMOD permissions on the test.txt file to read/write...
K. |
|
|
|
|
|
#7 |
|
Registered User
Join Date: Mar 2001
Posts: 9
|
I've done chmod 666 test.txt and text1.txt, where I'm reading them from. Clicking on the button which is supposed to call loadVariablesNum doesn't seem to do anything.
|
|
|
|
|
|
#8 |
|
Registered User
Join Date: Feb 2001
Location: vancouver
Posts: 2,219
|
Hmmm...
Do your variables exist on the root timeline? And are they being loaded from the movie on level 0? Other than that, I'm not sure why it's not working for you...sorry... K. |
|
|
|
|
|
#9 |
|
Registered User
Join Date: Mar 2001
Posts: 9
|
Yep, the text fields are directly on the stage. I used the debugger and it told me the variables were _level0.varname. It's a very simple movie, or so I thought! Thanks for your help - if you do come up with an answer let me know.
Cheers S. |
|
|
|
|
|
#10 |
|
Registered User
Join Date: Feb 2001
Location: Levittown, N.Y.
Posts: 25
|
Out of curiousity, is there any way to append this info so the text file can contain a list of say login users & passwords? Or must u have a database?
Flashlite |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Writing to text file | theMonitor | Flash 8 General Questions | 6 | 10-05-2006 04:40 PM |
| trying to create preloader for flat file text | mnk0 | ActionScript 2.0 | 1 | 05-26-2005 07:16 AM |
| External text loads partially & Render text as HTML prevents loading of text file | piercedwater | ActionScript 2.0 | 20 | 03-03-2005 12:33 AM |
| Writing to a text file using actionscript | sharadha | ActionScript 1.0 (and below) | 1 | 08-01-2002 08:08 AM |
| help writing to a text file | seniorcrap | Other Flash General Questions | 4 | 04-05-2002 06:04 AM |