AS3: Make a wordlist from a String of words
Working on dreamgrove.org i had to turn a string of space-separated words into a word list, an array containing these words, so that when someone searches for "red dress" i could get results using the String.search() method even when these words are not adjacent to each other (eg. "... her dress was red"). So i wrote a simple function that takes that string and returns an array of the words. Here is the code:
var string:String = "Google's mission is to organize the world's information and make it universally accessible and useful";
function wordlist(str:String):Array{
var wordlist:Array = new Array();
while(str.search(" ") != -1){
wordlist.push(str.substring(0, str.search(" ")));
str = str.substr(str.search(" ")+1);
trace(str);
}
wordlist.push(str);
return wordlist;
}
trace("\nlist: "+wordlist(string));And the output is:
mission is to organize the world's information and make it universally accessible and useful is to organize the world's information and make it universally accessible and useful to organize the world's information and make it universally accessible and useful organize the world's information and make it universally accessible and useful the world's information and make it universally accessible and useful world's information and make it universally accessible and useful information and make it universally accessible and useful and make it universally accessible and useful make it universally accessible and useful it universally accessible and useful universally accessible and useful accessible and useful and useful useful list: Google's,mission,is,to,organize,the,world's,information,and,make,it,universally,accessible,and,useful
Green Sock Tween
Well, for some time now i have been using TweenLite and especially TweenMax as my AS3 tweening engine. Jack has made an amazing job writing these classes and a real service to the Actionscript community by sharing them like this.
Now, i searched google for the terms "green" "sock" (which is the name of his blog) and the site was the 5th-6th result. And since this is unacceptable, there you have it; a whole blog post to boost by a tiny bit greensock's pagerank!