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

Jump randomly to specific frames HTML 5

New Here ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

Hello guys, I am working on an HTML5 canvas project in Adobe Animate.  Need a bit of help!! I would like my project to jump randomly to specific frames for example frame 5, 10 and 15 in a random order onload what is the required code to achieve this?

 

What I do know is;  

this.gotoAndStop(15+Math.random()*10);

Onload jumps my project between frame 15 and ending at frame 25. Which does work sweet, but doesn't meet my brief. I am guessing that this code needs modifying.

 

Kind regards

TOPICS
ActionScript , Code , How to

Views

1.4K

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 2 Correct answers

LEGEND , May 11, 2020 May 11, 2020

Create an array with the frames you want. Randomly select an element of that array.

Votes

Translate

Translate
Community Expert , May 11, 2020 May 11, 2020

this.frameA = [4,9,14,etc];

 

// on load of this frame: frameChangeF.bind(this)();

// on button click: this.button1.addEventListener("click",frameChangeF.bind(this));

function frameChangeF(){

this.gotoAndStop(this.frameA[Math.floor(Math.random()*this.frameA.length)]);

}

Votes

Translate

Translate
LEGEND ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

Create an array with the frames you want. Randomly select an element of that array.

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 ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

Thank you ClayUUID.

Would you be able to present me with an example?

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
Community Expert ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

this.frameA = [4,9,14,etc];

 

// on load of this frame: frameChangeF.bind(this)();

// on button click: this.button1.addEventListener("click",frameChangeF.bind(this));

function frameChangeF(){

this.gotoAndStop(this.frameA[Math.floor(Math.random()*this.frameA.length)]);

}

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 ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

LATEST

Thank you so much ClayUUID.

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