Monday, August 18, 2008

PHP's str_replace in Actionscript 3.0

PHP has a robust method for doing a string search and replace. The str_replace method can take in an array of elements to be searched and replaced and do the replace in one shot. Check out PHP's str_replace function's manual for details.

I just put together a TextUtils class with my Actionscript implementation of str_replace.

You can use it like below:
var content:String = "hello world";
trace(TextUtils.str_replace(["h","w"],["H","W"], content))
//outputs 'Hello World'
It gets interesting, when you gotta do something like this:
var content:String = "h.e.l.l.o; w,o,r,l,d";
trace(TextUtils.str_replace([",", ".", ";"], "", content))
//outputs 'hello world'

If you find it useful, go ahead and use it.

Of course, Actionscript 3.0 does have its own implementation of 'replace' function in the String class, which is pretty sleek as well. It also includes support for Regular Expression based search and replace. Check out the documentation AS3.0 String.replace here.

Thursday, August 14, 2008

New Virus in town - Under the name of 'Flash Player Installer'

A friend today got infected with a spam email.
The email's content goes

From: MSNBC Breaking News
Date: Wed, Aug 13, 2008 at 2:06 PM
Subject: - BREAKING NEWS: NASDAQ index gains 720 points overnight upon war announcement
To: **********@*****.com BREAKING NEWS: NASDAQ index gains 720 points overnight upon war announcement

Find out more at
See the top news of the day at, and the latest from Today Show and NBC Nightly News.

This e-mail is never sent unsolicited. You have received this MSNBC Breaking News Newsletter
newsletter because you subscribed to it or, someone forwarded it to you.
To remove yourself from the list (or to add yourself to the list if this
message was forwarded to you) simply go to, select unsubscribe, enter the
email address receiving this message, and click the Go button.

Microsoft Corporation - One Microsoft Way - Redmond, WA 98052

Naturally, he clicked on the link which read "" but was linking to a infected site. And was prompted to 'Install Flash player' . Now who doesn't want to install Flash player!!
So he "installed" clicking on the the link. At the time of me writing this, he is still figuring out how to clean up the mess!

There is only one way to make sure u won't fall for this trap. Always have the latest Flash player installed in your machine. ;)

If you haven't updated your flash player for long, go get it here.