how can i make this working? multiple mc instances
i wonna make a little game..
you have to hit the red circle, you have 3 seconds for it. the new circle shows up after one sec but the old ones should stay there cuz of the 3 seconds you got to hit it. if you dont hit each red circle in this 3 seconds it should be over and the score should show up but that does not work how it should aither cuz of the same problem. its a little bit more complex than i thought.
maybe you wonna take the code to try it.
i dont know how to make it working the most efficient way.
thanks for any help.
here is my code so far:
var myTimer:Timer = new Timer(1000,0);
// Event listeners:
myTimer.addEventListener("timer", myTimerAction);
//myTimer.addEventListener("timerComplete", myTimerComplete);
myTimer.start();
var count:Number = 0
var _mc:MovieClip = new MovieClip();
var errorTimer:Timer = new Timer(3000,1);
// Event handlers:
function myTimerAction(event:TimerEvent):void
{
trace(event.target.currentCount+" mal ausgelöst.");
// der Code
// der alle x Millisekunden
// ausgeführt wird.
// Event listeners:
errorTimer.addEventListener("timer", errorTimerAction);
errorTimer.addEventListener("errortimerComplete", errorTimerComplete);
errorTimer.start();
// Event handlers:;
function errorTimerAction(event:TimerEvent):void
{
myTimer.stop();
ergebnis.text = (count+" hast du geschafft");
}
function errorTimerComplete(event:TimerEvent):void
{
trace("Timer wird entfernt.");
errorTimer.removeEventListener("timer", errorTimerAction);
errorTimer.removeEventListener("timerComplete", errorTimerComplete);
}
var yrandomNum:Number = yrandomRange(70,947);
//y axenwert zufällig
function yrandomRange(minNum:Number, maxNum:Number):Number
{
return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);
}
var xrandomNum:Number = xrandomRange(70,570);
//x axenwert zufällig
function xrandomRange(minNum:Number, maxNum:Number):Number
{
return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);
}
function CustomCircle(xInput:Number,yInput:Number,rInput:Number,colorInput:uint)
{
_mc.graphics.beginFill(colorInput);
_mc.graphics.drawCircle(xInput, yInput, rInput);
}
CustomCircle(-35,35, 60, 0xFF3A00);
_mc.x = xrandomNum;
_mc.y = yrandomNum;
_mc.name = "mcButton";
addChild(_mc);
}
/**function myTimerComplete(event:TimerEvent):void
{
// Es ist immer eine gute Idee, Event listeners
// zu entfernen, wenn sie nicht mehr benötigt
// werden:
trace("Timer wird entfernt.");
myTimer.removeEventListener("timer", myTimerAction);
myTimer.removeEventListener("timerComplete", myTimerComplete);
}
**/
_mc.addEventListener(MouseEvent.CLICK, wennduklickst);
function wennduklickst(event:MouseEvent):void
{
removeChild(_mc);
errorTimer.stop();
count++;
}
