Testing Source Code

I just read this article from the team behind WordPress.

And I just wanted to test it out with a small chunk of code from my recently created Flash platform game.

		private function checkKeysDown (event:KeyboardEvent):void
		{
			if(event.keyCode == 37 || event.keyCode == 65) 			// A or Left Arrow
			{
				leftKeyDown = true;
				rightKeyDown = false;
			}

			if(event.keyCode == 38 || event.keyCode == 87) 			// W or Up Arrow
			{
				upKeyDown = true;
			}

			if(event.keyCode == 39 || event.keyCode == 68) 			// D or Right Arrow
			{
				rightKeyDown = true;
				leftKeyDown = false;
			}

			if(event.keyCode == 72 && !mainJumping) 				// H key
			{
				hKeyDown = true;
				sc4 = attack.play();
			}

			if(event.keyCode == 74 && !mainJumping) 				// J key
			{
				jKeyDown = true;
				sc4 = attack.play();
			}

			if(event.keyCode == 75 && !mainJumping) 				// K key
			{
				kKeyDown = true;
				sc4 = attack.play();
			}
		} // end private function checkKeysDown

Seems like it works wonderfully, I don’t know why I haven’t checked this functionality out before now. But I can see a lot of uses for this seeing as I’ve recently learned a lot of ActionScript 3.0 and will start learning more HTML and CSS in the following courses I have. Expect more posts consisting of code-strings in large amounts!

One awesome thing with this “plugin” is that it supports a lot of different programming languages; meaning that the plugin can color-code different syntaxes with various colors typically found within the language. It’s brilliant.

To insert code like this you simply write:

[*sourcecode language="css"]
your code here
[*/sourcecode]

Without the wildcard (*)

If you don’t define the source code language it will be “text” by default (no syntax highlighting). Here’s a list of the supported languages

  • actionscript3
  • bash
  • coldfusion
  • cpp
  • csharp
  • css
  • delphi
  • erlang
  • diff
  • groovy
  • javascript
  • java
  • javafx
  • objc
  • perl
  • php
  • text
  • powershell
  • python
  • ruby
  • scala
  • sql
  • vb
  • xml

Here’s the support post for the Source Code tagging.


About this entry