Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. COthanks for putting the code back again but it doesn't work allright for instance if the first part ends at frame 14, so if I fill in "1" in the texbox the animation schould stop at frame 14 right? Which numbers schould I fill in in this code if (runTimes > 0) { runTimes--; gotoAndPlay(<FIRST FRAME OF SECOND ANIMATION>); } else { gotoAndStop(<FRAME OF MAIN MENU>); } and where schould I place the code because it isn't clear for me but a great thanks for bringing me so far
      singulars
    2. COSo you don't want it to go back to the main menu afterwards you mean? If so, replace 'gotoAndStop(<FRAME OF MAIN MENU>);` simply with `stop();`. You want to put the code on a keyframe **after** the **last** frame of the animation. (Make sure it is a keyframe). (Also: if you are stopping on this frame, you will need to copy the contents across so it appears the same). [Example](http://i41.tinypic.com/n645y8.jpg)
      singulars
    3. COman this is harder than I thought.. haha I don't get it right so I explain it: in total I have 48 frames, the frist part ends on frame 12 and the second on 35, the frames beyond the 35 are to loop the animation more than once, so if you fill in "3" it plays part 1,2 and ends at the third time, so... do you get it?? I know it is hard to understand without using any moral communication but I am already very glad that you have helped me this far thanks for that
      singulars
 

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