Random Movie clip play

Ask a Question related to Macromedia Flash Actionscript, Design and Development.

  1. #1

    Default Random Movie clip play

    I have 7 different MovieClips. I put them into the main MovieClip which is on the stage. I want the 7 clips to play randomly when the .swf is loaded. I also want to put a random delay before each MovieClip starts.
    Any help is very much appreciated.

    Thanks in advance.

    Klick


    klick webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. random movie play
      Hi guys, I'm using flash 5 and I have a really simple question, how do I make a movie play randomly within my main movie. Once it's loaded the...
    2. play clip, remove clip, load new clip
      I have an empty 'container' MC that has a MovieClip load into it when a button is pressed.....when another button is pressed, it should play the...
    3. Duplicate Movie Clip in a Duplicated Movie Clip...
      I'm making a Flash Navigation Bar (menu) that could be freely customized by people just through a text file. The problem is that my submenus won't...
    4. Need help getting movie clip symbol to play
      I'm trying to use a movie clip symbol on one of my scenes. I've created a new layer for it and dragged it onto the stage from my library, but it...
    5. PLAY (EXECUTE) AVI OR QT CLIP INTO STAGE OR EXTERNAL MOVIE PLAYER
      HELLO To ALL Of the NG. I MUST "SIMPLY" MAKE TO EXECUTE (PLAYARE) A MOVIE CLIP QT Or AVI Or MPEG To the INSIDE Of the STAGE IN A FLASH MOVIE....
  3. #2

    Default Re: Random Movie clip play

    you'll need to put the names of your movieclips into an array or choose their names cleverly. then do you want your movieclips to play one after the other (in random order)? do you want to allow repeats or do you want to them each to play only once? if they each play only once what happens after the last plays?


    kglad webforumsuser@macromedia.com Guest

  4. #3

    Default Re: Random Movie clip play

    I need them to play in a random order they can double up if need be or just repeat after the seven have played. The other thing is can you put a random delay betwwen each movie clip playing? Thanks for the help.




    klick webforumsuser@macromedia.com Guest

  5. #4

    Default Re: Random Movie clip play

    mcA = new Array(); //put your movieclip names in here
    for (i=0; i<mcA.length; i++) {
    mcA._visible = 0;
    mcA.stop();
    }
    playmc();
    function playmc() {
    clearInterval(restartI);
    ind = Math.floor(Math.random()*7);
    mcA[ind]._visible = 1;
    mcA[ind].play();
    checkI = setInterval(checkF, 100, ind);
    }
    function checkF(ind) {
    if (mcA[ind]._currentFrame>=mcA[ind]._totalFrames) {
    mcA[ind].stop();
    mcA[ind]._visible = 0;
    clearInterval(checkI);
    restartI = setInterval(playmc, a*Math.random()+b);
    // assign a and b to meet your needs
    }


    kglad webforumsuser@macromedia.com Guest

  6. #5

    Default Re: Random Movie clip play

    Thanks so much I have been tossing and turning with this problem.


    klick webforumsuser@macromedia.com Guest

  7. #6

    Default Re: Random Movie clip play

    you're welcome.


    kglad webforumsuser@macromedia.com Guest

  8. #7

    Default Re: Random Movie clip play

    I apologize, I can't seem to get it to work. I'm not very good with arrays. The following is what I have. It is just basically what you gave me. How do I set up the Movie clips? Do I put your actionscript into scene 1 frame 1?

    Thanks for all your help.

    mcA = new Array();
    //put your movieclip names in here
    mcA = ["movie1", "movie2", "movie3", "movie4", "movie5", "movie6", "movie7"];
    for (ivar=0; ivar<mcA.length; ivar++) {
    mcA[ivar]._visible = 0;
    mcA[ivar].stop();
    }
    playmc();
    function playmc() {
    clearInterval(restartI);
    ind = Math.floor(Math.random()*7);
    mcA[ind]._visible = 1;
    mcA[ind].play();
    checkI = setInterval(checkF, 100, ind);
    }
    function checkF(ind) {
    if (mcA[ind]._currentFrame>=mcA[ind]._totalFrames) {
    mcA[ind].stop();
    mcA[ind]._visible = 0;
    clearInterval(checkI);
    restartI = setInterval(playmc, 2*Math.random()+1);
    // assign a and b to meet your needs
    }
    }


    klick webforumsuser@macromedia.com Guest

  9. #8

    Default Re: Random Movie clip play

    putting your movieclip names in quotes is going to cause a problem. flash things those array elements are strings and not movieclip objects. you can either tell flash to resolve those strings into objects by using bracket notation or remove those quotes and inform flash that those names movie1,movie2 etc are objects. btw, setInterval operates on milliseconds. i doubt you want to restart a new movie between 1 and 2 milliseconds. a=1000 and b=2000 is more likely what you want.


    kglad webforumsuser@macromedia.com Guest

  10. #9

    Default Re: Random Movie clip play

    You're not gonna belive this but I think I really did it, or I should say you did it! Thanks so much for the help.

    Klick


    klick webforumsuser@macromedia.com Guest

  11. #10

    Default Re: Random Movie clip play

    congrats! and you're welcome.


    kglad webforumsuser@macromedia.com Guest

  12. #11

    Default Re: Random Movie clip play

    i am using this code for another project and wasn't sure if you could help with another question... are you still answering questions
    Unregistered Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139