[F8] This is driving me MAD! Please Help
I am trying to read in a text file into flash 8. I want to read in the text file so that flash recognizes it then the output product is the same text but in flash. How do I accomplish this?
Senior Member
thanks for the help, like I didnt already think of that.
on your script layer you will have somthing like this:
var navigationVars:LoadVars = new LoadVars();
navigationVars.load("yourtextfile.txt");
navigationVars.onLoad = function(success:Boolean):Void {
if (success) {
yourtextbox .text = navigationVars.item1 ;
}
}
///////////////
In your text file you will have somthing like:
&item1 =Your info here bla bla.&
You have to have the and sign in the front and back info in the txt file. That's it. Make sure you have a dynamic text box on stage with a instance name of yourtextbox
Hope this helps.
Error msg
Everytime I go to load the txt file all I get is an error msg. This is the msg:
Error opening URL "file:///C:/ AreaGraph/ VR2Conversions/ SampleAsciiVR2files/ square.txt"
What am I doing wrong? Here is my script:
var navigationVars:LoadVars = new LoadVars();
navigationVars.load("C:/ AreaGraph/ VR2Conversions/ SampleAsciiVR2files/ square.txt");
navigationVars.onLoad = function(success:Boolean):Void {
if (success) {
mytextbox.text = navigationVars.item1;
}
};
C:/ AreaGraph/ VR2Conversions/ SampleAsciiVR2files/ square.txt
Looks like you have some extra spaces infront of each, should be this:
C:/AreaGraph/VR2Conversions/SampleAsciiVR2files/square.txt
Try that and see if that works, if that doens't work try putting the text file in the same location as your flash file so all you will need is:
navigationVars.load("square.txt");
So I created a folder that I put all my flash files in and I put the text file in that folder as well. I changed the file name to "square.txt" but all I am getting is a blank screen when I test it. I am no longer getting the error msg though. What could be going wrong?
Flashmatics
upload your files so we can see whats going on
files
I think I upload the file just let me know if you got them or not.
Attached Files
Flashmatics
put a stop() on your firstframe.. there is not textfield on your second frame that is why u see nothing
secondly keep the .txt file path relative to the .swf file..dont type in the whole computer path ..
e.g use
navigationVars.load("square.txt");
thirdly, i dont know what your data represents, but just by looking at it im guessing you would be better of using XML
I tried using XML but I was having problems with that as well. What I am going to eventually be doing once I read this file in is parse it out so that flash will read the coordinates on the file and create what is on that file.
Sounds like it is working just need to make sure on some things.
So basic questions:
1. Is your font same color as bg
2. font size big enough to see
Try to embed the letters somtime I have to do that for soem odd reason.
click on your text box and on the properties there should be a embed but click on that and in the input space add:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ.?!":;
And i bet you anything that will fix it.
Wow I am a slow typer, you already sent the file, let me take a look.
Last edited by jthompson3d; 08-23-2007 at 10:54 AM .
I tried to embed the characters and I am still getting a blank screen. Any other suggestions?
Ok found the problem.
for some odd reason flash doesn't like the item1 as a name.
change it to item2 in script and in txt file and it loads up fine.
Flashmatics
dm your code works fine on my side ..as i suggested put a stop() in frame one ...
Were you able to get it to display when you tested it?
Here is the code you need:
stop();
var navigationVars:LoadVars = new LoadVars();
navigationVars.load("square.txt");
navigationVars.onLoad = function(success:Boolean):Void {
if (success) {
mytextbox.text = navigationVars.item2;
}
};
also when yu embeded all that stuff before, take all that out.
Works fine now, I can see all the numbers headers etc.
Are you when you are testing it just getting part of the file on the screen? I am not getting all the coordinates.
Originally Posted by
dm2757
Are you when you are testing it just getting part of the file on the screen? I am not getting all the coordinates.
Take out all the embed text we did a bit ago. sorry
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width