3 Replies Latest reply on Jul 22, 2013 3:31 PM by circlemover

    setTimeout function when targeting a symbol timeline help

    circlemover

      Hi good people on the Edge

       

      Can any kind person help with writing a script snippet. 

       

      Both mysymbolname and mybtn are symbols that reside on the stage.  The script required must target the timeline of mysymbolname and play from mylabelname when mybtn is clicked on.  How can I then set a setTimeout function to play the timeline of mysymbolname from position mylabelname after someTimeT seconds? 

       

      In plainer English, the button when clicked will stop mysymbolname timeline and play will commence from mylabelname after some time has elapsed.

       

       

      So far, I have tried without success:

       

      sym.getSymbol(“mysymbolname”).stop();
      setTimeout(function(){sym.getSymbol(“mysymbolname”).play(“mylabelname”)},someTimeT);
      

       

      As an aside, mysymbolname timeline has triggers set to play the timeline after a defined time has passed using a setTimeout function.

       

      Will the command

       

      sym.getSymbol(“mysymbolname”).stop();
      

       

      Override these setTimeout function triggers and bring mysymbolname timeline to a complete stop? So that the setTimeout function will not trigger play of the timeline? I think this will be necessary when targeting mysymbolname timeline when mybtn is clicked.

       

      Any ideas most welcome.

        • 1. Re: setTimeout function when targeting a symbol timeline help
          AMULI Level 4

          Hi circlemover,

           

          The simplest solution is to drag and drop the transitions of your animation 2 s farer to create the timeout directly in the timeline

           

          But if you code it, changing the delay value is just a matter of editing it in your script.

           

          With the structure and the names you give, to fire the animation directly, you'll use this mybtn.click event handler :

           

          sym.getSymbol("mysymbolname").play("mylabelname");


          Now, to add a 2 s delay, replace it with

           

          sym.getSymbol("mysymbolname").stop("mylabelname");

           

          after having added a trigger at mylabelname :


          setTimeout( function(){sym.play()}, 2000);

           

          Downloadable example here : https://app.box.com/s/tq6f38kfaigb7w4xsn81

           

          Gil

          • 2. Re: setTimeout function when targeting a symbol timeline help
            AMULI Level 4

            Instead of using

             

            sym.getSymbol(“mysymbolname”).stop();


            just uncheck the autoplay property of your mysymbolname symbol to prevent it from playing.

             

            Gil

            1 person found this helpful
            • 3. Re: setTimeout function when targeting a symbol timeline help
              circlemover Level 1

              hi Amuli - nice of you to take time out to help, thankyou.

               

              I take on board what you sugguest and will report back when I can get back to the work in a couple of days.  Unfortuneatly, unchecking the autoplay property is not an option as the main timeline is set to loop continiously until the mybtn.click event handler is deployed by the user.

               

              Each symbol is built using setTimeout code to induce a delay at convenient timeline triggers as you describe:

               

              sym.stop();

              setTimeout( function(){sym.play()}, 3000);// set at position mylabelname along the symbol timeline

               

              The problem is when the mybtn.click event handler is deployed using

               

              sym.getSymbol("mysymbolname").stop("mylabelname");

              sym.getSymbol("mysymbolname").play("mylabelname");

               

              play of mysymbolname time line happens immediately and the trigger setTimeout code is ignored which is a bummer because I need the code to be recognised in order to keep all of the main timeline animations in sync.  I will have a close look again because I have not used

               

              sym.getSymbol("mysymbolname").stop("mylabelname");

               

              to evoke a stop at mylabelname I just coded .stop().   I am also thinking about clearTimers.  Maybe I need to clear all timers then stop the symbol timeline at mylabelname and then play. Thanks again anyway.