Return to Snippet

Revision: 9123
at October 22, 2008 04:22 by lzyy


Initial Code
//color egg
function colorEgg() 
{
    stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
    stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
    stage.addEventListener(Event.DEACTIVATE, clearKeys);
}

colorEgg();

var keyDowns = '';
function keyPressed(evt)
{
	//Tracer.debug(evt.keyCode);
	keyDowns += evt.keyCode.toString();
}

function keyReleased(evt)
{
	if(keyDowns == '76908989')
	{
		var txt:TextField = new TextField();
		txt.htmlText = '<font color="#ff6600" size="20" face="verdana"><b>YY , Have a Nice day :) - From LZ</b></font>';
		txt.x = stage.stageWidth - txt.textWidth;
		txt.y = stage.stageHeight - txt.textHeight;
		txt.width = txt.textWidth+10;
		txt.selectable = false;
		addChild(txt);
	}
}

function clearKeys(evt)
{
	keyDowns = '';
}

Initial URL

                                

Initial Description
可以通过特定的按键触发彩蛋

Initial Title
AS3 彩蛋 键盘事件

Initial Tags

                                

Initial Language
ActionScript 3