is it possible to count the amount of words in a dynamic text field in flash 8? thanks
Beyond Flash Your one stop web shop http://www.beyondflash.net
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.");}
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?"
another way is: Code: 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);
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
Forum Rules