actionscript 3 - Handeling Multiple TimerEvent -


The version of a game below is simplified, which I am making. In fact, there are some circles of the game. Each circle shoots are sent with timer events when the circle is clicked, then it is removed from the platform, however, the bullet still remains on dispatching. When this is clicked, then I can not understand every person's timer stop.

  var _timer: timer = new timer (1000); Var speed: int = 20; (Var i: int = 0; i & lt; = 3; i ++) for {var _shape: movie clip = new movie clip (); _shape.graphics.beginFill (0x999999); _shape.graphics.lineStyle (1, 0x000000); _shape.graphics.drawCircle (0, 0, 20); _shape.graphics.endFill (); AddChild (_shape); _shape.x = (stage.stageWidth) / 5; _shape.y = (stage.stageHeight) / 3 + _shape.height * i * 1.5; _shape.name = "_shape" + i; _shape.buttonMode = true; _shape.addEventListener (MouseEvent.CLICK, delete MOV clip); Bullets (_shape); } Function Tablets (_shape: Movieclip): zero {_timer = new timer (Math.rendum () * 100); _timer.addEventListener (TimerEvent.T.M.R., launching); _timer.start (); Start the function (e: timer event): zero {speed ++; Var _bullet: Movie Clip = New Movie Clip (); _bullet.graphics.beginFill (0x999999); _bullet.graphics.lineStyle (1, 0x000000); _bullet.graphics.drawRect (0, 0, 5, 2); _bullet.graphics.endFill (); AddChild (_bullet); _bullet.x = _shape.x + speed; _bullet.y = _shape.y; }} Delete the functionMovie Clip (e: MouseEvent): Zero {removeChild (getChildByName (e.currentTarget.name)); // How to Stop Timer Entts in the Clicked Circle? }  

Thanks in advance

  // Var _timer: timer = new timer (1000); // I do not think this is the required speed: int = 20; (Var i: int = 0; i & lt; = 3; i ++) for {var _shape: movie clip = new movie clip (); _shape.graphics.beginFill (0x999999); _shape.graphics.lineStyle (1, 0x000000); _shape.graphics.drawCircle (0, 0, 20); _shape.graphics.endFill (); AddChild (_shape); _shape.x = (stage.stageWidth) / 5; _shape.y = (stage.stageHeight) / 3 + _shape.height * i * 1.5; _shape.name = "_shape" + i; _shape.buttonMode = true; Bullets (_shape); } Function Pills (_shape: Movieclip): Nil {_shape.timer = New Timer (Math.Random) * 100); _shape.timer.addEventListener (TimerEventTMER, Getting Started); _shape.timer.start (); _shape.addEventListener (MouseEvent.CLICK, delete MOV clip); Start the function (e: timer event): zero {speed ++; Var _bullet: Movie Clip = New Movie Clip (); _bullet.graphics.beginFill (0x999999); _bullet.graphics.lineStyle (1, 0x000000); _bullet.graphics.drawRect (0, 0, 5, 2); _bullet.graphics.endFill (); AddChild (_bullet); _bullet.x = _shape.x + speed; _bullet.y = _shape.y; } Function RemovedMei Clip (E: MouseEvent): Stop Zero {// time and delete its listeners e.target.timer.stop (); // You may need to put it in the timer object e.target.timer.removeEventListener (TimerEvent.T.M.R., Start); RemoveChild ((MovieClip) e.target); // How to Stop Timer Entts in the Clicked Circle? }}  

Comments