The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> Flash Help
|
loading text from a .txt file
Discuss loading text from a .txt file in the Flash Help forum on Dev Shed. loading text from a .txt file Flash Help forum discussing all products originally created by Macromedia including DreamWeaver, Contribute, Flash, Fireworks, Freehand, Director, Authorware and HomeSite. Adobe bought Macromedia in 2005.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 20th, 2002, 03:02 PM
|
|
Member
|
|
Join Date: Oct 2001
Posts: 27
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
loading text from a .txt file
I would like my flash movie to load text from a .txt file so that when I want to add more text all I have to do is update the .txt file and can leave the flash movie alone. If anyone can walk me through this or direct me to a specific tutorial (not a website with tutorials) that covers this issue, please reply to this or email me. Thank you.
Eric
|

February 20th, 2002, 03:06 PM
|
|
Contributing User
|
|
Join Date: Oct 2000
Location: Back in the real world.
|
|
|
you can use getNetText and netResult (look in the flash manual, there are examples.) if you load it from a server.
if it is local, sorry, i donīt know.
|

February 20th, 2002, 04:14 PM
|
|
Member
|
|
Join Date: Oct 2001
Posts: 27
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
sorry but I think you missunderstood what I was trying to explain. I know how to work and edit the text file. I'm just not familiar with how to have the flash movie load text. I dont have a flash manual because I'm one of the millions out there that didn't get mine in a box  I know this can be done, I just dont know how to do it.
|

February 20th, 2002, 04:19 PM
|
|
Contributing User
|
|
Join Date: Oct 2000
Location: Back in the real world.
|
|
Quote:
sorry but I think you missunderstood what I was trying to explain. I know how to work and edit the text file. |
with notepad or from flash?
i didn think you were talking about EDITING a text file. just loading and make something like dynamic or localized menus.
from your first post:
Quote:
I would like my flash movie to load text from a .txt file so that when I want to add more text all I have to do is update the .txt file and can leave the flash movie alone. |
exactly this can be done using the functions i told you. if you donīt have the manual, just reply, i will try and find a sample for you...
|

February 20th, 2002, 04:46 PM
|
|
Member
|
|
Join Date: Oct 2001
Posts: 27
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Sorry that I missunderstood what you said. And reading back over my post, it may have come off as rude. I appologize if it did. But anywho.
Yeah, no manual. I'm a cheapo. A sample would be great. Thanks for your help.
|

February 20th, 2002, 04:54 PM
|
|
Contributing User
|
|
Join Date: Oct 2000
Location: Back in the real world.
|
|
nothing found i consider rude...
anyway, i try to make it up from my head since i only use flash at work:
netID=getNetText("http://www.myhost.com/myscript.php");
while (!netDone(netID)) {
(stay in this frame)
}
myText=netTextResult(netID);
_root.myTextObject.text=myText
sorry, this is not correct, i know. but from the html-help you should be able to make it work. if not, reply, i am sure someone is online that can do this. its an easy task after you made it work once... 
|

March 1st, 2002, 12:14 AM
|
|
Contributing User
|
|
Join Date: Jul 2001
Posts: 45
Time spent in forums: < 1 sec
Reputation Power: 12
|
|
|
Do you still need help with this?
|

March 1st, 2002, 01:51 AM
|
|
Member
|
|
Join Date: Oct 2001
Posts: 27
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
nah, I got it figured out. Thanks
|

March 28th, 2002, 10:05 AM
|
|
Junior Member
|
|
Join Date: Mar 2002
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
ASP CODE > UPDATING TEXT FILE ON THE FLY
Hi Eric,
You will need ASP Hosting for this solution
URL > have free hosting
I work on ecomerce/Database Driven Sites site done in Flash without using Macromedia Generator or other similar tools it is all done by hand in actionscript
I Currently only know ASP (Active Server Pages) and this is how to solve your problem
Firstly Copy the code below all code below between and including the "<%" + "%>" save this file as
"WriteTextFile.asp"
Then edit it in notepad and change the following lines
VariableContents = Request("FlashVariableContents")
The text between the quotes is name of the flash variable which is going to be sent ( This page excepts both GET and POST to send Variables)
The other line is as follows
TextFileName= "FlashVariables.txt"
The text between the quotes is name of text file and it relitive position from the flash movie at the moment it is in the same palace as the flash move
The Final line that needs to be changed is as follows
TextToWrite = "&VariableName=" & VariableContents
The text between the quotes is name of the variable in flash, The "&" Sign must be before the variableName then Follow Directly by the "=" Sign as shown below DO NOT Change any else on this line!
"&VariableName="
Contents of "WriteTextFile.asp"
<%
Const fsoForAppend = 8
Dim FileSystemObject
Dim FileSystemObject
Dim VariableContents
Dim TextToWrite
Dim TextFileName
Dim PathOfTextFile
TextFileName= "FlashVariables.txt"
PathOfTextFile = Server.MapPath(TextFileName")
VariableContents = Request("FlashVariableContents")
TextToWrite = "&VariableName=" & VariableContents
Set FileSystemObject = Server.CreateObject("Scripting.FileSystemObject")
Set objTextStream = FileSystemObject.OpenTextFile(, fsoForAppend)
objTextStream.Write TextToWrite
objTextStream.Close
Set objTextStream = Nothing
Set FileSystemObject = Nothing
%>
This will write the following to the text file
&VariableName=Testing123
If you have any problems Email Me StuffBoy
|

April 16th, 2002, 09:36 PM
|
|
Junior Member
|
|
Join Date: Apr 2002
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
External text file
I know you figured this out already but I thought I would add a solution that doesn't require any server side scripting. You can just edit the text file by hand, upload it to the server and flash reads it in...
In Flash:
- create a text field and name it 'stuff'
- create a button and add this script
on (press) {
loadVariablesNum ("textfile.txt", o);
}
In the textfile.txt, write:
stuff=This+is+the+text+you+want+displayed&otherVar=this+is+another+variable+named+otherVar+that+will+load+too
There are no quotes around any text. The end of a variable (and beginning of the next) is indicated by the '&' character. Spaces are not used. In a text string, a '+' character is used in place of a space.
NOTE: If you use special characters they will also be transferred. For example, if you use a return (character) in the file it will be transferred as part of the variable.
|

April 18th, 2002, 02:48 PM
|
|
Member
|
|
Join Date: Oct 2001
Posts: 27
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
adding on to this question.
okay so I got this stuff working a good time ago, but on a related note, does anyone know how to make it so that I can edit the text from the flash movie so that it saves it to the text file. That way the news or whatever can be updated from the movie itself.
any ideas?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|