A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Checking to see if a text field is empty or not!

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Location
    Columbus OH
    Posts
    178

    Checking to see if a text field is empty or not!

    I have 5 textfields in a mc called newsbox that reads in a txt file called news.txt. I have them scroll upwards and stop on each textfield to display the text in them for a few seconds and then continue scrolling to the next one. I want it to check to see if any of the textfields contain and empty string and if so, go to an play the first frame so that you don't see any dead space.

    This way, if I only have 2 pieces of news to tell you about, it won't continue to play through the other empty text fields that aren't reading anything from the news.txt file.

    How can I check to see if one is empty and then play the first frame to start the loop over again?

    I tried using this but it doesn't work.
    if(_root.newsbox.textfields.news2 eq ""){
    _root.newsbox.textfields.gotoAndPlay("start");
    }

    Thanks for your help.
    delstrange

  2. #2
    if(theTextBox.text == null)
    do stuff
    else dont

    you cant just reference the text box itself, as that is an object and if it exisits at all it is not null. You have to actually reference the string wich holds the contents of the text box, as this is only one of the many attributes a given text box object has

  3. #3
    Senior Member
    Join Date
    Oct 2002
    Posts
    175
    i thought you would have to reference it like...

    if(this.thetextbox.text==null)
    {
    Do your code;
    }

    since its part of a mc?

    Cedric

  4. #4
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    something like this perhaps?
    Code:
    if (!_root.newsbox.textfields.news2.text) {
    	_root.newsbox.textfields.gotoAndPlay("start");
    }
    I'm assuming news2 is the instance name of the textfield?

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Location
    Columbus OH
    Posts
    178
    okay, I have attached a zip file with the .txt that only has 2 variables with text in them. You'll see that it gets to the second piece of news and automatically goes back to the beginning when it should stay on it, and then jump to the beginning when it gets the third textfield because it is empty.

    Have a look and thanks for all of your help so far.
    Attached Files Attached Files
    delstrange

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