actionscript 3 - How to create live word counter in AS3 text field? -


i'm going create edit options in flash input text fields: need live word count. how count words user typing live?

try this, count groups of non-whitespace characters:

function countwords(input:string):int {     // match collections of non-whitespace characters.     return input.match(/[^\s]+/g).length; } 

some tests:

trace(countwords("")); // 0 trace(countwords("simple test.")); // 2 trace(countwords("    untrimmed string ")); // 5 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -