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

Randomly playing multiple instances of movieclip AS3

Community Beginner ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

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);
}
TOPICS
ActionScript

Views

396

Translate

Translate

Report

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
Advisor ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

did you give a different name to each mc?

Votes

Translate

Translate

Report

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 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

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:

animate_cc_as3_random_blink.gif

Code:

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

FLA download:

animate_cc_as3_random_blink.zip - Google Drive

Regards,

JC

Votes

Translate

Translate

Report

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 Beginner ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 Beginner ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

cries quietly bc i've been at this all day and your suggestion really got me closer than anything else, thank you so much, i appreciate it so much !!!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Excellent! You're welcome!

Votes

Translate

Translate

Report

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