Professional Web Applications Themes

Random Movie clip play - Macromedia Flash Actionscript

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...

  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. #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

  3. #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

  4. #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

  5. #5

    Default Re: Random Movie clip play

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


    klick webforumsuser@macromedia.com Guest

  6. #6

    Default Re: Random Movie clip play

    you're welcome.


    kglad webforumsuser@macromedia.com Guest

  7. #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

  8. #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

  9. #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

  10. #10

    Default Re: Random Movie clip play

    congrats! and you're welcome.


    kglad webforumsuser@macromedia.com Guest

  11. #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

Similar Threads

  1. random movie play
    By thishouseisclean in forum Macromedia Flash
    Replies: 2
    Last Post: February 29th, 10:42 PM
  2. play clip, remove clip, load new clip
    By Chris Waters in forum Macromedia Flash Actionscript
    Replies: 11
    Last Post: February 29th, 04:01 AM
  3. Duplicate Movie Clip in a Duplicated Movie Clip...
    By TommyHilfiger webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: February 2nd, 08:40 AM
  4. Need help getting movie clip symbol to play
    By Matt Stanley in forum Macromedia Flash Sitedesign
    Replies: 2
    Last Post: December 10th, 11:06 AM
  5. PLAY (EXECUTE) AVI OR QT CLIP INTO STAGE OR EXTERNAL MOVIE PLAYER
    By Max - 3D Artisan in forum Macromedia Flash
    Replies: 0
    Last Post: July 4th, 03:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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