3 Replies Latest reply on Feb 14, 2013 1:35 PM by Jr2dm

    Randomize Playback and Delay Help

    Jr2dm Level 1

      I have worked as a Flash developer, but I have pretty much no experience with JavaScript, so I'm at a loss with this issue. I'm attempting to recreate what was a Flash interactive completely in Edge Animate as close to the original file as possible.


      I have all of the animations I need setup as separate symbols already. My problems are as follow: firstly I need to setup one of these symbols so that it plays continuously but plays the timeline labels within the symbol in a random order. Effectively labels f1-f5 are randomly chosen by code and play, once that label section is done another label from the symbol is randomly chosen and plays, over and over again until the user interrupts it with a button click; which is the second part of my problem.


      I understand that I can place an “on release” type of function on a button to jump me to a label/section of the timeline to play a new animation (this is now referring back to the main timeline), my problem is working in conjunction with the previous randomly playing symbol I need for the “on release” code to wait until the current random animation finishes before it plays the button started animation. Meaning the randomized symbol is currently playing label f3 when the user clicks the button to jump the main timeline to symbol t2, the code recognizes that the user has clicked a button and waits until f3’s animation has finished before it jumps to t2.


      Also, with this complexity of code (I think it seems rather complex) would it be better for me to break up the randomized symbol into its individual animations (five independent symbols rather than one) so that all of the labels are in a single timeline and then just setup some sort of an array for the randomness?


      Thanks for any help you all can offer, also if I managed to confuse you with how I've asked the questions please point out where the confusion is and I'll try to clarify.

        • 1. Re: Randomize Playback and Delay Help
          Jr2dm Level 1

          Ok, let's try this from a different approach. I have laid out my symbols across the timeline and lead each of them with a timeline label. What I need is for is on the frame before each label to have a set of code that would have an if/then statement (coming at this from a Flash perspective so I apologize for any incorrect syntax/wording but I hope I get the intent across) looking for a button click, if there has been no button click select a random label (1-5) and jump to and play. If there was a button click read the code in the button and jump to and play the label the button points to. Likewise I need an if/then statement on the button that says on release wait until the playhead reaches the previous code I mentioned before jumping to and playing the label it points to.

          • 2. Re: Randomize Playback and Delay Help
            elainecc Adobe Employee

            Hi, jr2dm-


            You can do most of this by maintaining state manually.  I have a blog post that talks about how to do that (search for "state management").  As for the randomization, you can use the Math.random() function and do some fancy coding to get you a random number between 0 and 4.  It's actually more or less the same as what you would do in ActionScript, so it should look fairly familiar:


            // gives you a random number between 0 and 4

            var randomNumber = Math.floor(Math.random() * 10) % 5;


            Hope that helps!



            • 3. Re: Randomize Playback and Delay Help
              Jr2dm Level 1

              Thanks for pointing me in the right direction for this. I'm out of the office now for the weekend but I'll be sure to try and figure my way through this when I get back in and I'll let you know where I get stuck next.