You are here: Home > News > "Konami Code" Experiments

"Konami Code" Experiments

Sometimes, you need a break in your activities, to prevent the burnout. For that reason, I've decided to stop working on SPAS for the weekend and doing some funny stuff, such as...
...writting lines of code!

So, after having drunk some alcohol with few friends of mine, I've decided to work on the greatest innovation ever made over the world : the Konami Code!

 

The Konami Code ActionScript API

Because the Konami code is very popular among developers, I decided to add my experiments around the Konami code in the API SPAS. To enable developers to access this ActionScript API independently of the entire SPAS framework, the Konami code API is a part of the Top Level API : org.flashapi.toplevel.

The following sample application shows how it is easy to use the Konami code API. Place the focus on the application and type the Konami code:

Get Adobe Flash player

package {
	
	import flash.events.KeyboardEvent;
	import org.flashapi.swing.Alert;
	import org.flashapi.swing.Application;
	import org.flashapi.swing.Text;
	import org.flashapi.toplevel.event.KonCodEvent;
	import org.flashapi.toplevel.io.KonCodController;
	
	public class konCodTest extends Application {
		
		public function konCodTest() {
			super(init);
		}
		
		private var _kcc:KonCodController;
		private var _alertMsg:Alert;
		
		private function init():void {
			initController();
			$stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
			_alertMsg = new Alert("Congratulations");
			_alertMsg.message = ("Congratulations, ura geek!");
			var msg:Text = new Text(150, 50);
			msg.text = "Please click and type the Konami Code.";
			this.addElement(msg);
		}
		
		private function initController():void {
			_kcc = new KonCodController();
			_kcc.addEventListener(KonCodEvent.KON_COD_CHECK, konCodCheckHandler);
		}
		
		private function keyUpHandler(e:KeyboardEvent):void {
			_kcc.setNext(e.keyCode);
		}
		
		private function konCodCheckHandler(e:KonCodEvent):void {
			_alertMsg.display();
		}
	}
}

The Konami Code Java and Javascript APIs

Once I've finished the implementation of the Konami Code for the ActionScript language, I made a of portage of the API to both Java and Javascript.

You can download these APIs by clicking here and directly try the Javascript implementation on this page.

Conclusion

As a conclusion of the preceding experiments, I would say that, even if Java is more powerful than AS3 and Javascript is becoming more popular every day, the ActionScript 3.0 event handling model is still the best, and probably for a long time.

People who do not use ActionScript, or who only know the Flex MXML event tags, say that Java is better than Flash on this point. But maybe, they should consider the fact that, since the version 3.0, ActionScript is a strongly event oriented language. For that reason, the ActionScript 3.0 event handling model is much more efficient and easy-to-use than the Java model.

Share this article:

Comments:

There are no comments yet for this article.

Leave a reply

Your email is required but will not be displayed.

To prevent abusive emails, please enter the numbers you see in the image below:

Security code