• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Animate random keyframe selection

New Here ,
Dec 06, 2017 Dec 06, 2017

Copy link to clipboard

Copied

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?

Views

277

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 07, 2017 Dec 07, 2017

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?

Votes

Translate

Translate
LEGEND ,
Dec 06, 2017 Dec 06, 2017

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 06, 2017 Dec 06, 2017

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 07, 2017 Dec 07, 2017

Copy link to clipboard

Copied

LATEST

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines