3 Replies Latest reply on Dec 7, 2017 7:56 AM by robdillon

    Animate random keyframe selection

    sc41097207

      I'm trying to make a simple True/False game in Animate.  I need the game to randomly select a question out of 10 options, ask each question once (no repeats).  I have the game questions on labeled keyframes ("q1", "q2"...)  I've tried several suggestions that I found online, and none seem to work--creating array, not creating array, using variables.  I don't have any example code to show, as nothing is coming close to working.  Any suggestions?

        • 1. Re: Animate random keyframe selection
          robdillon Most Valuable Participant

          Is this for Actionscript or for an HTML5 Canvas file? What do you want to have happen when the user chooses the correct versus the incorrect answer? Can you share the sample files that you have tried that failed for you? Can you tell us why they didn’t work for you?

          1 person found this helpful
          • 2. Re: Animate random keyframe selection
            sc41097207 Level 1

            HTML5 Canvas.

            When the user chooses the correct answer, the score should augment +1, and they should be taken to the next randomly selected keyframe.  User does not need to be taken to a "correct!" type frame.

            When I've tried to put in anything random, it breaks the game, and I'm (obviously) not knowledgable enough to fix it.

             

            The only code I still have on hand is:

            var adFramesA = ["q1","q2","q3"];

              this.gotoAndPlay(adFramesA[Math.floor(adFramesA.length*Math.random())]);

            I got this from an online source, so don't know much about it.  If there's an online suggestion for how to do this, I've tried it with no success.

            • 3. Re: Animate random keyframe selection
              robdillon Most Valuable Participant

              There is nothing wrong with your code above. It works just fine for me in a standalone file. You say that using random breaks the file, can you give a more complete description of what is happening?