A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] Help with reading infomation from a txt file

Hybrid View

  1. #1
    Eternal Newbie
    Join Date
    Apr 2006
    Location
    Bitter cold Hell of the crappy NW
    Posts
    392

    [F8] Help with reading infomation from a txt file

    Hello all!

    I am having a slight problem with my AS these days. I have 2 items on my stage, an input box with the var of "wordMatch"

    A button

    and a dynamic text field with the var of "matchWord"

    uploaded to the server I have words.txt. inside words.txt it looks like this (example):

    Code:
    hi
    hello
    howdy
    hola
    What I am looking for is very simple I just can't manage to get it working:

    I want the user to input a word in the txt box, click the button and have Flash check if it is in the list. If it IS in the list, then the dynamic text box says "Yay, it's in the list" and if not "Sorry it's not in the list"

    Simple it seems, as nothing else needs to happen, I just can't get it to go correctly.

    Any help?

    ~MoN
    If I am wrong, please just correct me and move on.. there is no need for all that pointing and laughing! ~MoN

  2. #2
    Eternal Newbie
    Join Date
    Apr 2006
    Location
    Bitter cold Hell of the crappy NW
    Posts
    392
    I guess that would be 3 items on stage, not 2 heh.

    No one knows? Am I in the wrong spot? I thought I had it working, but it just broke, and wasn't doing it right to begin with.

    Starting over step one...

    making my items on the stage.

    Next comes AS, if anyone out there can help me

    ~MoN
    If I am wrong, please just correct me and move on.. there is no need for all that pointing and laughing! ~MoN

  3. #3
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Here's a start, but it read from internal array, not txt file.
    Code:
    var txtList = new Array("hi", "hello", "howdy", "hola");
    //
    btn.onRelease = function() {
    	var foundIt = false;
    	for (var i = 0; i < txtList.length; i++) {
    		if (txtList[i] == wordMatch) {
    			foundIt = true;
    			break;
    		}
    	}
    	if (foundIt) {
    		matchWord = "Yay, it's in the list.";
    	} else {
    		matchWord = "Sorry it's not in the list.";
    	}
    };

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Here's an example.
    Don't use var.
    Attached Files Attached Files

  5. #5
    Eternal Newbie
    Join Date
    Apr 2006
    Location
    Bitter cold Hell of the crappy NW
    Posts
    392
    Great! Thanks for the advice! I will look and pick apart this code and see how it all works!

    I appreciate it greatly!

    ~MoN
    If I am wrong, please just correct me and move on.. there is no need for all that pointing and laughing! ~MoN

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