There are lots of programs that do this for you, just google block websites!
http://www.ashkon.com/webblock.html
If you want to do it with the hosts file, just add the lines (like you have done), but remember to add the sub domains, like
www.
so you would add
127.0.0.1 myspace.com
127.0.0.1
www.myspace.com
127.0.0.1 ads.myspace.com
etc
For more info, look here
http://www.allthingsmarked.com/2006/08/28/howto-block-websites-using-the-hosts-file/