A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 58

Thread: [F8] Writing an array in a text file

  1. #1
    Member
    Join Date
    Aug 2007
    Posts
    87

    [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?

  2. #2
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    LodVars google it
    ~calmchess~

  3. #3
    Member
    Join Date
    Aug 2007
    Posts
    87
    thanks for the help, like I didnt already think of that.

  4. #4
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    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.

  5. #5
    Member
    Join Date
    Aug 2007
    Posts
    87

    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;
    }
    };

  6. #6
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    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");

  7. #7
    Member
    Join Date
    Aug 2007
    Posts
    87
    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?

  8. #8
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    upload your files so we can see whats going on
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  9. #9
    Member
    Join Date
    Aug 2007
    Posts
    87

    files

    I think I upload the file just let me know if you got them or not.
    Attached Files Attached Files

  10. #10
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    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
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  11. #11
    Member
    Join Date
    Aug 2007
    Posts
    87
    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.

  12. #12
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    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.

  13. #13
    Member
    Join Date
    Aug 2007
    Posts
    87
    I tried to embed the characters and I am still getting a blank screen. Any other suggestions?

  14. #14
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    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.

  15. #15
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    dm your code works fine on my side ..as i suggested put a stop() in frame one ...
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  16. #16
    Member
    Join Date
    Aug 2007
    Posts
    87
    Were you able to get it to display when you tested it?

  17. #17
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    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;
    }
    };

  18. #18
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    also when yu embeded all that stuff before, take all that out.

    Works fine now, I can see all the numbers headers etc.

  19. #19
    Member
    Join Date
    Aug 2007
    Posts
    87
    Are you when you are testing it just getting part of the file on the screen? I am not getting all the coordinates.

  20. #20
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    Quote 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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center