A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [Help] importing a .txt file, but with certain objectives to fulfill

  1. #1
    Senior Member
    Join Date
    Aug 2006
    Posts
    110

    [Help] importing a .txt file, but with certain objectives to fulfill

    Hi, all. I've been working on a gameshow game that I would like to present to a special interests club somewhere, and I've created a nice Wheel of Fortune-style game. Everything is done about it, and it looks nice. But I left the hardest part for last, which is what I want to ask about.

    I'm sure I could figure this beginning part out myself, but given that this is just the beginning of my question, I figured I'd also ask it anyway: Could somebody give me a quick runthrough of how importing a .txt file is done? How should I set up my instances and actionscript? I remember trying it before a while ago, but never got it to work. But my objective is not to simply output text. I want to use it for a specifiy purpose.

    This is the question I really wanted to ask:

    How would I go about separating each new line in the .txt file as a new "object"?
    Basically, the text file will consist of X number of lines, each line representing a different Phrase for my Wheel of Fortune game. However, on this same line, I will also include the Category after a certain token character is used (e.g. "/").

    My basic view of how the text file would look would be like this:

    Box of Cheese/Thing
    Schoolyard/Place
    Orson Welles/Person

    ...and I would add to this file as I come up with more phrases.

    I realize that I could make this all internal within my ActionScript, but I don't intend on leaving my source file with other people, but rather leave the option for them to create the .txt file with their own phrases to use.

    Once I can get this part understood, I am sure I can figure out how to integrate it into my game. (or else, I'll just ask here again for advice )

    Thanks.

    EDIT: After thinking about it for a little while more, I'd like to refine how I'm importing the stuff in the .txt file. I would probably be taking each character one-by-one and stuffing them onto the board.
    Last edited by The Chow; 12-03-2006 at 03:12 AM.
    "I dreamt that I was a 'Genie-Firefighter'! I fought fires ...and granted wishes!"

  2. #2
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    i would use xml instead, its a good for formatting data into a nice readable.

    <phrases>

    <thing>
    <phrase>Box of Cheese</phrase>
    </thing>

    <place>
    <phrase>Schoolyard</phrase>
    </place>

    <person>
    <phrase>Orson Welles</phrase>
    </person>

    </phrases>
    lather yourself up with soap - soap arcade

  3. #3
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    xml is advanced version and always recommended over txt files.

    However, if you still wish to stick with txt you have to give each phrase name and separate them with &:

    phrase1=Box of Cheese/Thing&phrase2=Schoolyard/Place&phrase3=Orson Welles/Person

    Once the txt is loaded, you will have access to those variables in your game and you can use split function to get category from the string value.

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