Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I was you, the way I would approach this is by having a keyframe after each of the animations where you can type some code.</p> <p>On the menu page or where ever you have the code for how many times the code should run, define a variable and call it something like "runTimes" which should become the amount of times the animation should run.</p> <p>At the end of the animations do a simple if statement to check what the value of "runTimes" is and then decrement it. Depending on the value, it should use gotoAndPlay/gotoAndStop.</p> <p>So, put this on the keyframe after the first animation:</p> <pre><code>if (runTimes &gt; 0) { runTimes--; gotoAndPlay(&lt;FIRST FRAME OF SECOND ANIMATION&gt;); } else { gotoAndStop(&lt;FRAME OF MAIN MENU&gt;); } </code></pre> <p>and this after the second animation:</p> <pre><code>if (runTimes &gt; 0) { runTimes--; gotoAndPlay(&lt;FIRST FRAME OF FIRST ANIMATION&gt;); } else { gotoAndStop(&lt;FRAME OF MAIN MENU&gt;); } </code></pre> <p>On the mainmenu frame, let's assume you have a textbox named "numTimes_txt" for the number of times to play and a button "playAnimations_btn" to start the animations.</p> <pre><code>import flash.events.MouseEvent; var runTimes:int = 0; playAnimations_btn.addEventListener(MouseEvent.CLICK, playAnims); function playAnims(e:MouseEvent):void { runTimes = parseInt(numTimes_txt.text); play(); // or gotoAndPlay(&lt;FIRST FRAME OF FIRST ANIMATION&gt;); } </code></pre> <p>I haven't tested this as I don't have my IDE on me right now, but this should work if I understand the question properly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload