Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Mar 16, 2018 Mar 16, 2018

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); }
TOPICS
ActionScript
269
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2018 Mar 17, 2018
LATEST

don't remove the eventlistener.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines