Tag Archives: Flash

Flash AS3 – CharCodeStrings Library (download)

A few weeks ago I was working on an interesting text typing widget for our new website (that isn’t up yet, still in the works). I came to find that there was a Keyboard.CharCodeStrings Array Constant in the AS3 Language reference–but it was only available within the AIR 1.0 runtime. Bummer.

So like many folks out there, I needed to roll a homegrown solution to match up CharCode result numbers with their character counterparts. Essentially a singleton class that you can use when you catch your event and turn the resulting CharCode into a literal string character.

Here is an example:

package {
	import flash.events.KeyboardEvent;
	import flash.display.MovieClip;
	import com.iq.CharCodeStrings;
	public class CharCodeStrings_sample extends MovieClip {
 
		public function CharCodeStrings_sample() {
			stage.addEventListener(KeyboardEvent.KEY_DOWN, traceKey);
		}
		public function traceKey(event:KeyboardEvent):void {
			var myChar:String = CharCodeStrings.getChar(event.charCode);
			trace(myChar);
		}
	}
}

If this may be useful to you, there is a download link below. I built this to do what I needed for the project I was working on, so the character codes returned are for US English–but you could easily substitute another language by using the included sample app and replacing the characters. If you do set this up for use in another language feel free to shoot me the file and I will link it here.

Download CharCodeStrings

(Hint, when testing from within the Flash IDE turn off Keyboard Shortcuts when you run your movie to test or the preview window may not receive keyboard input. It is in the Control menu when your swf is playing.)

Google Maps API for Flash!

Looks like Google is releasing a Flash API for Google Maps.

This should be something fun to play with down the road.

Google Maps API @ Google Code