7 Replies Latest reply on Oct 1, 2012 3:01 PM by TimJaramillo

    Random display banner

    shagon13

      Hello,

       

      I created a slideshow with 3 different banners. I would like to make them show up as random when user refresh their broswer.

       

      As of right now, I have slide 1, 2 then 3 in that order. I also created label for each of the slide in the timeline. Is there a script for me to make each of the slide to display randomly?

       

      Thank you.

        • 1. Re: Random display banner
          TimJaramillo Level 4

          Hi shagon13,

           

          Uncheck the "autoplay" checkbox, and add the code below to your Stage/compositionReady event (this is assuming your frame labels are "frame1", "frame2", etc. This plays from a random label on your root Stage timeline.

           

          // function to get random value within range

          sym.randomNumRange = function(from, to){

             //return 1;

             return Math.floor(Math.random() * (to - from + 1) + from);

          }

           

           

          // set variable to random number within range

          sym.playFromValue = sym.randomNumRange(1, 3);

           

           

          // play from random value on root Stage timeline

          sym.play("frame"+sym.playFromValue);

           

          Hope this helps!

          Tim

          • 2. Re: Random display banner
            shagon13 Level 1

            Hi Tim,

             

            Thank you for taking your time and response to my thread. I have another question. If I have more than 3 slides, and I decide not to have them display at all in the slideshow.

             

            For example, I currently have 5 slides, but I only want 3 to be random. Is there a code to do so?

             

            Also, do I place your script on the fist frame of the stage?

             

            Thank you again and I really am appreciate your support.

            Shagon

            • 3. Re: Random display banner
              TimJaramillo Level 4

              Hi shagon13,

               

              Per my post, you should place that code on the Stage/compositionReady event. You can access this Stage event by clicking the curly braces next to the Stage div in the Elements panel. See attached screenshot.stage_event.jpg

               

              I'm not clear on what you mean by this: "For example, I currently have 5 slides, but I only want 3 to be random. Is there a code to do so?" Can you try to explain more? What are you trying to randomize? The order in which the slides play in sequence?

              • 4. Re: Random display banner
                shagon13 Level 1

                Thanks for the screen shot, it makes a whole lot of sense now. Please disregard about my 5 slides question.

                • 5. Re: Random display banner
                  TimJaramillo Level 4

                  Cool, glad it makes sense to you!

                   

                  Btw, you might want to double check- I think you selected your last question as the "Correct" answer for this thread, rather than one of my answers.

                   

                  Cheers!

                  • 6. Re: Random display banner
                    shagon13 Level 1

                    I went back and check your post as correct. As you can see, I'm a newbie in this forum. Cheers.

                    • 7. Re: Random display banner
                      TimJaramillo Level 4

                      Hehe, that's ok shagon13, we were all newbies at some point in our life!

                       

                      Good luck with Edge!