Posts Tagged ‘type’

Switch-case for object’s class type

Friday, August 31st, 2012

Quick tip; instead of using a bunch of “if (x is y) else if (x is z) else” conditionals, you can simply get the class of any object using the “constructor” property. It’s not exposed trough strict typing though, so you have to typecast your instance to Object to access it.

This allows you to have a switch-case for an object’s class:

function addShape(shape:Shape):void {
	switch (Object(shape).constructor) {
		case Circle:
			trace("It's a circle");
			break;
		case Square:
			trace("It's a square");
			break;
		default:
			trace("Unknown shape");
	}
}

Flv and f4v files not found on IIS

Wednesday, May 5th, 2010

If your IIS server throws a “404 not found” page every time you try to fetch a flash video file (flv or f4v), your server might be missing the MIME type declaration.
In the Internet Information Services Manager, right click the local computer server and select Properties, open MIME types, click New and enter the following for flv (technote):

Associated Extension box: .FLV
MIME Type box: flv-application/octet-stream

and for f4v (technote):

Associated Extension box: .F4V
MIME Type box: video/mp4

Digging around the internet, I’ve found people reporting these MIME types working too;
video/x-flv for .flv files, and
video/f4v for .f4v files.

Be advised that you may have to restart IIS for the changes to work.