[SWF(frameRate=24)]
var arrX:Array=[291,376,441,436,292,138,164,290];
var arrY:Array=[44,77,158,297,302,265,140,193];
input_txt.restrict="0-9";
_txt.mouseEnabled=false;
var showCount:int=0;
var myCount:int=10;
var hitCount:int=0;
var bl:Boolean=false;
/四个变量/
var mc:Mc=new Mc();
var t:Timer;
_btn.addEventListener(MouseEvent.MOUSE_DOWN,down);
function down(e) {
showCount=0;
myCount=int(input_txt.text);
hitCount=0;
t=new Timer(1000);
t.start();
t.addEventListener(TimerEvent.TIMER,onTimer);
addEventListener(Event.ENTER_FRAME,frame);
_btn.visible=false;
}
function onTimer(e) {
addChild(mc);
mc.alpha=1;
var ind:int=Math.random()*8;
mc.x=arrX[ind];
mc.y=arrY[ind];
bl=true;
showCount++;
}
stage.addEventListener(MouseEvent.CLICK,onClick);
function onClick(e) {
if (mc.hitTestPoint(mouseX,mouseY)&&bl==true) {
hitCount++;
bl=false;
mc.alpha=0.5;
}
}
var huanChong:int=0;
function frame(e) {
_txt.text="出现:"+showCount+"次 击中:"+hitCount+"次";
if (showCount>=myCount) {
huanChong++;
if (huanChong>=20) {
huanChong=0;
t.reset();
t.removeEventListener(TimerEvent.TIMER,onTimer);
removeEventListener(Event.ENTER_FRAME,frame);
_btn.visible=true;
removeChild(mc);
}
}
if (myCount==hitCount) {
_txt.text="出现:"+showCount+"次 击中:"+hitCount+"次."+"真准!";
}
}