Skip to main content
Participant
March 17, 2018
質問

How can I make this eye animation in Flash loop continuously after removing Event Listener?

  • March 17, 2018
  • 返信数 1.
  • 307 ビュー

favorite

I have made a movieclip of an eye, which is set to play a blinking animation at random intervals. I have multiple instances on the stage, and when I play it, there's maybe 1-2 seconds of blinking and then it stops completely. How can I make it loop?

I had to add the removeEventListener at the end because Flash would crash if I didn't, I think because it was infinitely loading the function or something.

The code is placed inside the eye movie clip.

this.gotoAndStop(1); 
var eye:Eye = new Eye();
var eyeTimer = new Timer(1000 + Math.random() * 1000);
eyeTimer
.addEventListener(TimerEvent.TIMER, blink);
eyeTimer
.start();
function blink(evt:TimerEvent😞void
{ Timer(evt.currentTarget).delay = 1000 + Math.random() * 1000;  trace( "triggered!" );
this.gotoAndPlay(1); eyeTimer.removeEventListener(TimerEvent.TIMER, blink); }
このトピックへの返信は締め切られました。

返信数 1

kglad
Community Expert
Community Expert
March 17, 2018

don't remove the eventlistener.