Skip to main content
Participant
March 16, 2018
Question

Randomly playing multiple instances of movieclip AS3

  • March 16, 2018
  • 2 replies
  • 571 views

I have made a movieclip of an eye, which is set to play a blinking animation at random intervals. I want to place many instances of that movieclip on the stage, where they're all being played at different times. But if I put multiple instances of the clip on the stage, only one will play. How do I have many instances playing at the same time?

I haven't used flash for years so please explain simply if you can~

stop(); 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!" ); eye.gotoAndPlay(1);
}
This topic has been closed for replies.

2 replies

JoãoCésar17023019
Community Expert
Community Expert
March 16, 2018

Hi.

I myself would rather prefer to put a simple randomization code inside of a container Movie Clip containing two eyes -- considering that they have to blink at the same time.

In this way, you'll won't have a headache trying to reference each Miovie Clip in different frames, nested in different timelines, using tweening, and so on.

Preview:

Code:

gotoAndPlay(Math.ceil(Math.random() * 150));

FLA download:

animate_cc_as3_random_blink.zip - Google Drive

Regards,

JC

FuureAuthor
Participant
March 17, 2018

Would love to download the assets but the link doesn't work. Also I'm animating individual eyes, not connected to each other.

JoãoCésar17023019
Community Expert
Community Expert
March 17, 2018

I'm really sorry about the link!

That's the second time this week that Googgle blocks a link of mine.

Anyway, I edited my comment with a valid link this time! I hope it can be helpful.

Robert Mc Dowell
Legend
March 16, 2018

did you give a different name to each mc?