Skip to main content
Known Participant
November 18, 2020
Question

REPEATING A (SET OF) FRAME(S) FOR A CERTAIN TIME

  • November 18, 2020
  • 2 replies
  • 1678 views

I am very new so please do not be offended by my basic questions which - despite searching the net - I could not answer.
So far I have only mastered the art of button-controlled-branching to other frames.
So yes when a user presses a button the program branches to a set of 10 slides called "slide17"  (on frames 170 to 179 - keyframe = frame 170).

Now I would like to code the following:

On the background (stage image) of these frames (170-179) I want to play some animations and then - without the user pressing any buttons - return to keyframe 10 (which I called "slide1").

My thought was to tell adobe animate to 
   - "gotoAndPlay("slide17")  - "for a certain time - (20 seconds)"   
   - in this time performing some motion tweens on the screen background (stage image)
   - and then automatically banch to frame 10   = >   gotoAndStop("slide1");

How could I code this - to "stay on a frame for a certain time" ?

 

Kind regards,  William-Michael

    This topic has been closed for replies.

    2 replies

    kglad
    Community Expert
    Community Expert
    November 19, 2020

    you're welcome.

    Known Participant
    November 19, 2020

    Hi Kglad, 
    One more question, though:
    I somehow seemed to have lost my AS3 code:
    When I click Window / Actions the panel opens with the keyframes with code on the left side but with no code on the right side.

    Interestingly the test run worked as normal so the code must be somewhere
    The question is where  did it go.
    If this is a clue - for some reason I cannot click on the keyframes on the left (when I click a keyframe on the cursor goes away.
    How can I get my cod back?

     

    Thank you for your assistance - 

    KInd regards,   William Michael

    Known Participant
    November 19, 2020

    If this is any clue::  The symbols to the right of the text "Add using a wizard" are all dimmed.

    William Michael

    kglad
    Community Expert
    Community Expert
    November 18, 2020

    canvas or as3?

     

    what's the animation on frames 170-179?

     

    if it's a movieclip on keyframe 170, start a loop and repeatedly check for the last frame of that movieclip.  when reached return to "slide1".

    Known Participant
    November 19, 2020

    Hi Kglad,

    Sorry, I do not yet know what canvas is – so I think it will be movie clip – something dropping from the sky.
    Case in point: My program change is an add a motion tween in between 2 already existing slides (slide 0 and slide 1) of a (button-controlled) slide show.
    1.  Ideally I would add 10 frames in between slide 0 and 1:  But how?
    There is a possibility to “add a frame”.
    But when I add this frame it only changes the one layer where the play-head is in.
    E.g. if I selected e.g. the layer “actions” and then right click “Add Frame” – it will add a frame to the “actions” layer but not to the other layers. If I need to redo the 17 slides with all the interactive buttons and artwork, this would take too long

    1. To bypass this problem I simply added 10 frames at the end (frame 170 to 179), called them “slide17” and branch to them instead of slide 1  (= instead of gotoAndPlay(“slide1”)   it is now gotoAndPlay(“slide17”)

    3. Now what you say re. repeating  I had already done:
    (I arrive in keyframe 170 (“slide17”) via a user button click in slide 0.)
    Actions in
    Key frame 170:   stop();
    Keyframe 179:    gotoAndPlay(“slide17”)
    But how do I tell Animate to interrupt this endless loop ca. 20 seconds later and branch back to “slide1”

    4. Ideally this could be a time setting per frame. I did not find one.
    So I tried to find an instruction like For I = 1 to 40  gotoAndPlay(“slide17”)
    As I could not find any info about such a loop instruction on the net I got in contact with Adobe Help.
    But they told me I should try to find an answer in discussions on this portal.
    They gave me a link to a 1054 page developer manual which handles mainly graphic issues.
    Strangely there seems to be no AS3 instruction manual

     

    All sorts of thoughts appear in my mind - like why not try to make a sep. motion tween slide and Call the subprogram - but how is this done.

     

    Thank you for any assistance you can give me in this matter.

    William Michael

    Known Participant
    November 19, 2020

    To Kglad:
    I got it working now!
    To share the experience I enclose the code that I used with good success
    The time at which the frames (170-179) and (180-189) show up can be manipulated by setting
    numPlayed17 = 24;
    numPlayed18 = 24;
    in keyframe 1 actions to a larger or shorter value.
    The effect,  to have each set of frames on stage for a while to run tweens is now working.

    Thank you for your advice to re-check my looping....

    Kind regards,       William Michael 

     

    In Keyframe 1:

    import flash.events.MouseEvent;

    var numPlayed17:Number = 0;
    var numPlayed18:Number = 0;

    function stageClickHandler(e:MouseEvent):void
    {
    if  (e.target.name === "start1_btn")
    {
    numPlayed17 = 24;
    numPlayed18 = 24;
    gotoAndPlay("slide17");
    }

    (... (there are checks for further buttons and they all work very well)

     

    In keyframe 179:

    if (numPlayed17 > 0) {

                    numPlayed17 = numPlayed17-1;

                    gotoAndPlay("slide17");

                    } else {

                    gotoAndPlay("slide18");

    }

     

    In keyframe 189:

    if (numPlayed18 > 0) {

                    numPlayed18 = numPlayed18-1;

        gotoAndPlay("slide18");

                    } else {

                    gotoAndPlay("slide1");

    }