Postcode Widget – Part 1


July 31, 2008

Background

After playing around with Google maps for a few days it became apparent that having a list of UK postcodes plus the corresponding latitude and longitude to each would come in very handy for a lot of people. If you had such a thing you could build loads of exciting applications, from route planning to food mile calculators.

The problem is that here in the UK the list doesn’t exist in the public domain. It’s available from the Post Office, but it’ll cost you, making it effectively useless for most small groups and enterprises.

What’s currently available from Easypeasy is the first half of the code. With this you can break the UK into about 3,000 separate parts, narrowing a location to within a few kilometres.

Project Brief

There appear to be two groups pushing the Postcode into the public domain, Free the Postcode and New Popular Edition Maps.

What I’d like to do is build a widget that people can put on their website that makes it easy for the general public to enter their Postcode, and help build the free database. Currently you are required to specifically visit either of the two website and with Free the Postcode know by heart your latitude and longitude.

Using the Google Map API combined with the first half of the postcode the widget would pull up a map of your local area, from here it’s easy to stick a pin where you live or work, and then after (an email?) authentication your postcode is added to the database.

References

Free the Postcode: www.freethepostcode.org

New Popular Edition Maps: www.npemap.org.uk

Postcode Schema: www.govtalk.gov.uk/gdsc/html/frames/PostCode.htm

Easypeasy: www.easypeasy.com/guides/article.php?article=64

A Simple Actionscript Class Definition


July 30, 2008

I know I’m a little late to the party on this one but I finally cracked Flash Classes last weekend – yay!

To be honest there wasn’t really a whole lot to crack, just the definitions of private and public functions.

Essentially a public function will execute when the class is initialised, and a private function will wait to be called, and that’s all there is to it .

Try this out:

In a text editor create a file and name it TestClass.as

Type the following:

class TestClass{

	public function foo(){
		trace(“Hello from Foo”);
	}

	private function baa(){
		trace(“Hello from Baa”);
	}

}

Now create a new Flash document and save it in the same folder as TestClass.as

On frame one (or any other) type:

var myTestClass = new TestClass();

now publish your movie and you should get the output “Hello from Foo”

If you now add the following line:

myTestClass.baa();

publish your movie and you should get the output “Hello from Foo”, “Hello from Baa”

Yes, it really is that easy!