PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
counting words in text field
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: counting words in text field

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jul 2002
    New Mexico

    counting words in text field

    is it possible to count the amount of words in a dynamic text field in flash 8?

    Beyond Flash
    Your one stop web shop

  2. #2
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    This works, although I'm not sure it would in every instance.
    Actionscript Code:
    dt.text = "this is just a test to see if counting the words in a dynamic text can be done.";

    b.onRelease = function() {
        for(var i = 0; i < dt.text.length; i++) {
            String.prototype.countChars = function(arg) {
                return this.split(arg).length - 1;
            str = dt.text;
            num = str.countChars(" ");
            words = num + 1;
        trace("There are " + words + " words.");
    Wile E. Coyote - "Clear as mud?"

  3. #3
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    London, UK
    another way is:

    myText = "this is just a test to see if counting the words in a dynamic text can be done."
    trace("the number of words: "+ myText.split(" ").length);
    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

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