March 6, 2010

How to access query string arguments with AS3

Category: ActionScript, khadlock at 11:49 am

Found a great blog post with an ActionScript 2 class that parses the current URL and creates accessible properties out of query string arguments: http://blog.circlecube.com/2008/03/20/get-current-url-and-query-string-parameters-to-flash-tutorial/

I needed something to parse any URL, so I made a few adjustments and converted the class to AS3. Here's the updated code:

package
{
	import flash.external.*;
 
	public class QueryString
	{
		private var _queryString:String;
		private var _all:String;
		private var _params:Object;
 
		public function QueryString(url:String='')
		{
			readQueryString(url);
		}
		public function get getQueryString():String
		{
			return _queryString;
		}
		public function get url():String
		{
			return _all;
		}
		public function get parameters():Object
		{
			return _params;
		}		
 
		private function readQueryString(url:String=''):void
		{
			_params = new Object();
			try
			{
				_all = (url.length > 0) ? url : ExternalInterface.call("window.location.href.toString");
				_queryString = (url.length > 0) ? url.split("?")[1] : ExternalInterface.call("window.location.search.substring", 1);
				if(_queryString)
				{
					var allParams:Array = _queryString.split('&');
					//var length:uint = params.length;
 
					for(var i:int=0, index=-1; i < allParams.length; i++)
					{
						var keyValuePair:String = allParams[i];
						if((index = keyValuePair.indexOf("=")) > 0)
						{
							var paramKey:String = keyValuePair.substring(0,index);
							var paramValue:String = keyValuePair.substring(index+1);
							_params[paramKey] = paramValue;
						}
					}
				}
			}
			catch(e:Error)
			{
				trace("Some error occured. ExternalInterface doesn't work in Standalone player.");
			}
		}
	}
}

Here's an example of how to use the updated version:

 
var myPath:QueryString = new QueryString("http://www.studiosedition.com/?page=articles");
trace(myPath.parameters.page);
 

It's as simple as passing a URL with a query string and then just use the parameters object to access the specific query argument, in this case we're accessing the page argument, which will give us a value of "articles".

Bookmark and Share

 

February 11, 2010

How to convert audio to mp3 with iTunes

Category: Audio, Tags: , khadlock at 11:11 pm

I know mp3 conversion has been possible in iTunes forever, but I never needed it until today and I figured others may find it useful. If you need to convert an audio file to an mp3 you can use iTunes by following these steps:

  1. Open "Preferences", click "Import Settings..." and choose "MP3 encoder" as the Import Format.
  2. Now you can right-click on any of the songs in your library and choose "Create MP3 Version".

itunes-mp3

Bookmark and Share

 

February 3, 2010

OVO Creative Group launched their new web site

Category: JavaScript, PHP, Tags: , , , , khadlock at 1:22 am

OVO is a branding consultancy specializing in naming, visual identity and integrated marketing for organizations seeking to launch, grow or reinvent themselves. We developed OVO's web site based on their original designs. Using PHP and MySQL we created a content management system (CMS) for OVO to manage their client projects and organize their project slideshows. We also developed a custom JavaScript slideshow widget that randomizes and animates OVO's projects based on a custom JSON feed. Read more...

Bookmark and Share

 

February 2, 2010

The One Less Flight website has been released

Category: Graphic Design, PHP, Tags: , , , , khadlock at 12:24 pm

Miskeeto, a world-class user experience strategy and evaluation consultancy led by Robert Hoekman, Jr. recently released the web site One Less Flight (OLF). We designed and developed OLF based on Robert's concept of getting companies and individuals to commit to reducing carbon emissions by taking one less flight each year. The concept was to offer badges/banners for people to put on their web site to show their commitment to the cause. By adding the badge to a web site the domain of that web site would appear on the OLF web site to feature the commitment.

I looked into a few ways of making the domain addition work; trackbacks, pingbacks and refbacks. I ended up choosing refbacks because pingbacks and trackbacks are limited to working only with other trackback-enabled or pingback-enabled web sites, which essentially limited the site to working with other blogs. On the other hand, the refback method allows anyone to use a badge on their site and automatically appear on OLF regardless of how their site is set up.

The custom refback method works through the actual image request. The image request goes through php, which does the following:

  1. It verifies that the domain has not already been added to a list of linked domains.
  2. It adds it to the list if it does not already exist.
  3. It then returns the image based on the banner requested.
  4. When someone comes to OLF the list is read and the domains are displayed.

Here's the result: One Less Flight

Special thanks to Stephanie Sullivan for her beautiful CSS coding of my original design!

Bookmark and Share

 

January 22, 2010

Download any video from YouTube

Category: Video, Tags: , , khadlock at 2:20 pm

Found this site that lets you download any video from YouTube by simply entering the URL to the video you want to download. http://keepvid.com

Bookmark and Share

 

Older Posts »