Playing with AS3 – An example MP3 player component

I have finally gotten around to playing with AS3, and I decided to pick the Sound object as one to play with. In the end, I ended up creating a simple music playback “component” that uses a whole number of AS3 features. I am including the example here along with the source. Enjoy! Note: error handling is not yet very robust, but it still shows numerous aspects of AS3 in use. Requires Flash Player 9.

Grrrr… WordPress is munging the object and embed tags. The example can be seen here for the moment.

An Algorithm for Finding Common Elements Across Data Sets

I was recently working on a search algorithm for a Flash piece I am working on, and the way the algorithm worked involved doing separate searches for each keyword from an index that I had created, recording the number of occurrences for each keyword, then finding out which elements were common between each of the keywords. I came up with an algorithm to do this operation linearly, that is it only has to do one pass through the data which means that it scales well for large data sets. The gist is that if you have three sets of data, then any data element needs to appear three times in the search for it to be common across the data sets. As such, all that is needed is a tally kept of how many times each data element appears and anything that has a tally of three is part of the intersection of the data sets.

Note: this only works if there are no duplicated elements in each data set, which fortunately is not too hard a condition to impose.

Here is some code representing the algorithm: