Source Code
import flash.ui.Mouse; import flash.events.MouseEvent; import flash.utils.Timer; import flash.events.TimerEvent; import flash.text.engine.TypographicCase; var nR:uint = 0; var nMin:uint = 1; var nMax:uint = 15; var nScore:uint = 0; stage.addChild(myMouse); myMouse.mouseEnabled = false; myMouse.addEventListener(Event.ENTER_FRAME, fnMyMouse); function fnMyMouse(event:Event):void { myMouse.x = stage.mouseX; myMouse.y = stage.mouseY; } Mouse.hide(); var gTimer:Timer; gTimer = new Timer(500, 0); gTimer.addEventListener(TimerEvent.TIMER, fnRandom); gTimer.start(); for (var i:int = nMin; i <= nMax; i++) { this["m"+i].gotoAndPlay(i); this["m"+i].addEventListener(MouseEvent.CLICK, onClick(i)); this["m"+i].visible = false; } function onClick(j:int):Function { return function(event:MouseEvent):void { fnScore(j); } } function fnScore(k:int) { nScore++ ; this["m"+k].visible = false; txtScore.text = nScore.toString(); } function fnRandom(event:TimerEvent):void { nR = Math.floor(Math.random() * (1 + nMax - nMin) + nMin); this["m"+nR].visible = true; }สวัสดี มีความสุข